Skip to content

Commit 76007a8

Browse files
committed
Merge branch '2.18' into 2.19
2 parents 79b2de3 + 53f3469 commit 76007a8

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

release-notes/CREDITS-2.x

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,11 @@ Tomáš Poledný (@Saljack)
18721872
multiple constructors since 2.18
18731873
(2.18.3)
18741874

1875+
Gustavo Bazan (@gssbzn)
1876+
* Reported #4908: Deserialization behavior change with @JsonCreator and
1877+
@ConstructorProperties between 2.17 and 2.18
1878+
(2.18.3)
1879+
18751880
Liam Feid (@fxshlein)
18761881
* Contributed #1467: Support `@JsonUnwrapped` with `@JsonCreator`
18771882
(2.19.0)

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ Project: jackson-databind
5858
multiple constructors since 2.18
5959
(reported by Tomáš P)
6060
(fix by Joo-Hyuk K, @cowtowncoder)
61+
#4908: Deserialization behavior change with @JsonCreator and
62+
@ConstructorProperties between 2.17 and 2.18
63+
(reported by Gustavo B)
6164
6265
2.18.2 (27-Nov-2024)
6366

src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,8 +1464,16 @@ public JsonCreator.Mode findCreatorBinding(Annotated a) {
14641464
@Override
14651465
public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) {
14661466
JsonCreator ann = _findAnnotation(a, JsonCreator.class);
1467-
if (ann != null) {
1468-
return ann.mode();
1467+
JsonCreator.Mode mode;
1468+
if (ann == null) {
1469+
mode = null;
1470+
} else {
1471+
mode = ann.mode();
1472+
// 25-Jan-2025, tatu: [databind#4809] Need to avoid "DEFAULT" from masking
1473+
// @CreatorProperties-provided value
1474+
if (mode != JsonCreator.Mode.DEFAULT) {
1475+
return mode;
1476+
}
14691477
}
14701478
if (_cfgConstructorPropertiesImpliesCreator
14711479
&& config.isEnabled(MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES)
@@ -1481,7 +1489,7 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
14811489
}
14821490
}
14831491
}
1484-
return null;
1492+
return mode;
14851493
}
14861494

14871495
/*

src/test/java/com/fasterxml/jackson/databind/deser/creators/CreatorPropertiesTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,27 @@ public void testSkipNonScalar3252() throws Exception
148148
//System.err.println("JsON: "+MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(testData));
149149
assertEquals(3, testData.size());
150150
}
151+
152+
static class Something4908 {
153+
@JsonProperty("value")
154+
private final String _value;
155+
156+
String getValue() {
157+
return _value;
158+
}
159+
160+
@JsonCreator
161+
@ConstructorProperties({"value"})
162+
Something4908(String pValue) {
163+
_value = pValue;
164+
}
165+
}
166+
167+
// [databind#4908] @ConstructorProperties and @JsonCreator
168+
@Test
169+
public void testConstructorPropertyAndJsonCreator() throws Exception {
170+
Something4908 value = MAPPER.readValue(a2q("{'value':'abc'}"),
171+
Something4908.class);
172+
assertEquals("abc", value.getValue());
173+
}
151174
}

0 commit comments

Comments
 (0)