Skip to content

Commit

Permalink
Merge branch '2.18' into 2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 26, 2025
2 parents 79b2de3 + 53f3469 commit 76007a8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,11 @@ Tomáš Poledný (@Saljack)
multiple constructors since 2.18
(2.18.3)

Gustavo Bazan (@gssbzn)
* Reported #4908: Deserialization behavior change with @JsonCreator and
@ConstructorProperties between 2.17 and 2.18
(2.18.3)

Liam Feid (@fxshlein)
* Contributed #1467: Support `@JsonUnwrapped` with `@JsonCreator`
(2.19.0)
Expand Down
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Project: jackson-databind
multiple constructors since 2.18
(reported by Tomáš P)
(fix by Joo-Hyuk K, @cowtowncoder)
#4908: Deserialization behavior change with @JsonCreator and
@ConstructorProperties between 2.17 and 2.18
(reported by Gustavo B)
2.18.2 (27-Nov-2024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1464,8 +1464,16 @@ public JsonCreator.Mode findCreatorBinding(Annotated a) {
@Override
public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated a) {
JsonCreator ann = _findAnnotation(a, JsonCreator.class);
if (ann != null) {
return ann.mode();
JsonCreator.Mode mode;
if (ann == null) {
mode = null;
} else {
mode = ann.mode();
// 25-Jan-2025, tatu: [databind#4809] Need to avoid "DEFAULT" from masking
// @CreatorProperties-provided value
if (mode != JsonCreator.Mode.DEFAULT) {
return mode;
}
}
if (_cfgConstructorPropertiesImpliesCreator
&& config.isEnabled(MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES)
Expand All @@ -1481,7 +1489,7 @@ public JsonCreator.Mode findCreatorAnnotation(MapperConfig<?> config, Annotated
}
}
}
return null;
return mode;
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,27 @@ public void testSkipNonScalar3252() throws Exception
//System.err.println("JsON: "+MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(testData));
assertEquals(3, testData.size());
}

static class Something4908 {
@JsonProperty("value")
private final String _value;

String getValue() {
return _value;
}

@JsonCreator
@ConstructorProperties({"value"})
Something4908(String pValue) {
_value = pValue;
}
}

// [databind#4908] @ConstructorProperties and @JsonCreator
@Test
public void testConstructorPropertyAndJsonCreator() throws Exception {
Something4908 value = MAPPER.readValue(a2q("{'value':'abc'}"),
Something4908.class);
assertEquals("abc", value.getValue());
}
}

0 comments on commit 76007a8

Please sign in to comment.