Skip to content

Deserialization behavior change with @JsonCreator and @ConstructorProperties between 2.17 and 2.18 #4908

@gssbzn

Description

@gssbzn

Search before asking

  • I searched in the issues and found nothing similar.

Describe the bug

We maintain a large codebase which has some legacy classes that use Hungarian notation and lombok,

Deserialization used to work up until the 2.18 update where jackson is no longer respecting the @ConstructorProperties to match the constructor properties and we are now seeing cannot deserialize from Object value (no delegate- or property-based Creator) errors.

This may be related to INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES and the recent rewrite POJO Property Introspection

Version Information

2.18.2

Reproduction

@Test
  void deserialization() throws JsonProcessingException {
    var json =
        """
{
  "value": "test"
}
""";
    var result = new ObjectMapper().readValue(json, Something.class); // throws error

    assertEquals("test", result.getValue());
  }

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

    String getValue() {
      return _value;
    }

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

Expected behavior

jackson should be able to leverage @ConstructorProperties for the @JsonCreator

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.18Issues planned at 2.18 or later

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions