Skip to content

Commit 60fbb91

Browse files
committed
Merge branch '2.18' into 2.19
2 parents 76007a8 + 681e399 commit 60fbb91

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Project: jackson-databind
6161
#4908: Deserialization behavior change with @JsonCreator and
6262
@ConstructorProperties between 2.17 and 2.18
6363
(reported by Gustavo B)
64+
#4922: Failing `@JsonMerge` with a custom Map
65+
(reported by @nlisker)
6466
6567
2.18.2 (27-Nov-2024)
6668
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.fasterxml.jackson.databind.deser.merge;
2+
3+
import java.util.*;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
import com.fasterxml.jackson.annotation.JsonMerge;
8+
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
10+
11+
import static org.junit.jupiter.api.Assertions.*;
12+
13+
@SuppressWarnings("serial")
14+
public class CustomMapMerge4922Test
15+
extends DatabindTestUtil
16+
{
17+
// [databind#4922]
18+
interface MyMap4922<K, V> extends Map<K, V> {}
19+
20+
static class MapImpl<K, V> extends HashMap<K, V> implements MyMap4922<K, V> {}
21+
22+
static class MergeMap4922 {
23+
@JsonMerge // either here
24+
public MyMap4922<Integer, String> map = new MapImpl<>();
25+
}
26+
27+
private final ObjectMapper MAPPER = newJsonMapper();
28+
29+
// [databind#4922]: Merge for custom maps fails
30+
@Test
31+
void testJDKMapperReading() throws Exception {
32+
MergeMap4922 input = new MergeMap4922();
33+
input.map.put(3, "ADS");
34+
35+
String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input);
36+
MergeMap4922 merge2 = MAPPER.readValue(json, MergeMap4922.class);
37+
assertNotNull(merge2);
38+
}
39+
40+
}

0 commit comments

Comments
 (0)