-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or later
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
Hey there,
We recently upgraded to Jackson 2.18.1, and we're now encountering an issue when we try to deserialize a class with multiple constructors. We're using the ParameterNamesModule so that we don't need to add the @JsonCreator annotation.
@Getter
@RequiredArgsConstructor
public static class Param {
private final String foo;
private final String bar;
}
@Getter
public static class A {
private final String foo;
private final String bar;
public A(String foo, String bar) {
this.foo = foo;
this.bar = bar;
}
public A(Param param) {
this.foo = param.getFoo();
this.bar = param.getBar();
}
}
@Test
void deserializationTest() throws JsonProcessingException {
ObjectMapper objectMapper = JsonMapper.builder().addModule(new ParameterNamesModule()).build();
A desA = objectMapper.readValue("""
{
"foo": "foo",
"bar": "bar"
}""", A.class);
assertThat(desA.getFoo()).isEqualTo("foo");
assertThat(desA.getBar()).isEqualTo("bar");
}
We're aware that the documentation for the ParameterNamesModule states that the module only works if there is only one constructor. However, the example worked for us with version 2.17.3. We would like to clarify whether this behavior is intended?
Version Information
2.18.1, 2.18.2
Reproduction
see code sample in description
Expected behavior
deserialization works
Additional context
No response
Metadata
Metadata
Assignees
Labels
2.18Issues planned at 2.18 or laterIssues planned at 2.18 or later