Skip to content

Commit c4406ec

Browse files
committed
Merge branch '2.19'
2 parents 81c04f0 + 60fbb91 commit c4406ec

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package tools.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+
9+
import tools.jackson.databind.ObjectMapper;
10+
import tools.jackson.databind.testutil.DatabindTestUtil;
11+
12+
import static org.junit.jupiter.api.Assertions.*;
13+
14+
@SuppressWarnings("serial")
15+
public class CustomMapMerge4922Test
16+
extends DatabindTestUtil
17+
{
18+
// [databind#4922]
19+
interface MyMap4922<K, V> extends Map<K, V> {}
20+
21+
static class MapImpl<K, V> extends HashMap<K, V> implements MyMap4922<K, V> {}
22+
23+
static class MergeMap4922 {
24+
@JsonMerge // either here
25+
public MyMap4922<Integer, String> map = new MapImpl<>();
26+
}
27+
28+
private final ObjectMapper MAPPER = newJsonMapper();
29+
30+
// [databind#4922]: Merge for custom maps fails
31+
@Test
32+
void testJDKMapperReading() throws Exception {
33+
MergeMap4922 input = new MergeMap4922();
34+
input.map.put(3, "ADS");
35+
36+
String json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(input);
37+
MergeMap4922 merge2 = MAPPER.readValue(json, MergeMap4922.class);
38+
assertNotNull(merge2);
39+
}
40+
41+
}

0 commit comments

Comments
 (0)