Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
gssbzn opened this issue Jan 15, 2025 · 1 comment
Labels
to-evaluate Issue that has been received but not yet evaluated

Comments

@gssbzn
Copy link

gssbzn commented Jan 15, 2025

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

@gssbzn gssbzn added the to-evaluate Issue that has been received but not yet evaluated label Jan 15, 2025
@cowtowncoder
Copy link
Member

Thank you for reporting this @gssbzn. It definitely sounds like bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-evaluate Issue that has been received but not yet evaluated
Projects
None yet
Development

No branches or pull requests

2 participants