Skip to content

Commit e232ef1

Browse files
authored
Add tests to show #5372 (#5374)
1 parent fade17f commit e232ef1

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

release-notes/VERSION

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ Versions: 3.x (for earlier see VERSION-2.x)
55
=== Releases ===
66
------------------------------------------------------------------------
77

8+
3.1.0 (not yet released)
9+
10+
-
11+
12+
3.0.2 (not yet released)
13+
14+
#5372: Wrong setter is used when deserializing from `InputStream` (or `byte[]`)
15+
(NOTE: actual fix via jackson-core#1491)
16+
(reported by @quaff)
17+
818
3.0.1 (21-Oct-2025)
919

1020
#5335: JsonMapper to deserialize `Optional.empty()` instead of `null`

src/test/java/tools/jackson/databind/misc/ParsingContext2525Test.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package tools.jackson.databind.misc;
22

3-
import java.io.IOException;
4-
53
import org.junit.jupiter.api.Test;
64

75
import tools.jackson.core.*;
@@ -72,7 +70,7 @@ public void testFullDocWithBuffer() throws Exception
7270
}
7371
}
7472

75-
private TokenBuffer _readAsTokenBuffer(String doc) throws IOException
73+
private TokenBuffer _readAsTokenBuffer(String doc)
7674
{
7775
try (JsonParser p = MAPPER.createParser(doc)) {
7876
p.nextToken();
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package tools.jackson.databind.misc;
2+
3+
import java.io.StringReader;
4+
import java.io.ByteArrayInputStream;
5+
import java.nio.charset.StandardCharsets;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
import tools.jackson.databind.ObjectMapper;
10+
import tools.jackson.databind.testutil.DatabindTestUtil;
11+
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
14+
// [databind#5372]: Property name mismatch problem,
15+
// caused by [core#1491]; verify that databind usage fixed as well
16+
public class PropertyMismatch5372Test extends DatabindTestUtil
17+
{
18+
static class TestObject5372 {
19+
private String aaaabbbbcccc;
20+
private String aaaabbbbcccc2;
21+
22+
public String getAaaabbbbcccc2() {
23+
return aaaabbbbcccc2;
24+
}
25+
26+
public void setAaaabbbbcccc2(String aaaabbbbcccc2) {
27+
this.aaaabbbbcccc2 = aaaabbbbcccc2;
28+
}
29+
30+
public String getAaaabbbbcccc() {
31+
return aaaabbbbcccc;
32+
}
33+
34+
public void setAaaabbbbcccc(String aaaabbbbcccc) {
35+
this.aaaabbbbcccc = aaaabbbbcccc;
36+
}
37+
}
38+
39+
private final String KEY_1 = "aaaabbbbcccc";
40+
private final String KEY_2 = "aaaabbbbcccc2";
41+
42+
private final String DOC_5372 = """
43+
{
44+
"%s": "v3",
45+
"%s": "v4"
46+
}
47+
""".formatted(KEY_1, KEY_2);
48+
49+
private final ObjectMapper MAPPER = newJsonMapper();
50+
51+
@Test
52+
void testIssue5372Bytes() throws Exception
53+
{
54+
final byte[] bytes = DOC_5372.getBytes(StandardCharsets.UTF_8);
55+
_assert5372(MAPPER.readValue(bytes, TestObject5372.class));
56+
_assert5372(MAPPER.readValue(new ByteArrayInputStream(bytes), TestObject5372.class));
57+
}
58+
59+
@Test
60+
void testIssue5372Chars() throws Exception
61+
{
62+
_assert5372(MAPPER.readValue(DOC_5372, TestObject5372.class));
63+
_assert5372(MAPPER.readValue(new StringReader(DOC_5372), TestObject5372.class));
64+
}
65+
66+
private void _assert5372(TestObject5372 result) {
67+
assertEquals("v3", result.getAaaabbbbcccc());
68+
assertEquals("v4", result.getAaaabbbbcccc2());
69+
}
70+
}

0 commit comments

Comments
 (0)