Skip to content

Commit 81c04f0

Browse files
committed
Merge branch '2.19'
2 parents 19bcc0b + 76007a8 commit 81c04f0

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/tools/jackson/databind/introspect/JacksonAnnotationIntrospector.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,8 +1341,16 @@ public Boolean findMergeInfo(MapperConfig<?> config, Annotated a) {
13411341
@Override
13421342
public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) {
13431343
JsonCreator ann = _findAnnotation(a, JsonCreator.class);
1344-
if (ann != null) {
1345-
return ann.mode();
1344+
JsonCreator.Mode mode;
1345+
if (ann == null) {
1346+
mode = null;
1347+
} else {
1348+
mode = ann.mode();
1349+
// 25-Jan-2025, tatu: [databind#4809] Need to avoid "DEFAULT" from masking
1350+
// @CreatorProperties-provided value
1351+
if (mode != JsonCreator.Mode.DEFAULT) {
1352+
return mode;
1353+
}
13461354
}
13471355
if (_cfgConstructorPropertiesImpliesCreator
13481356
&& config.isEnabled(MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES)
@@ -1356,7 +1364,7 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
13561364
}
13571365
}
13581366
}
1359-
return null;
1367+
return mode;
13601368
}
13611369

13621370
/*

src/test/java/tools/jackson/databind/ext/desktop/ConstructorPropertiesAnnotationTest.java

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

0 commit comments

Comments
 (0)