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

Add MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @ConstructorProperties as explicit @JsonCreator equivalent #1371

Closed
cowtowncoder opened this issue Sep 14, 2016 · 5 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented Sep 14, 2016

One challenge with frameworks like Lombok, auto-values and Immutables is that they often automatically (or at least by default) add JDK7 JDK6 @ ConstructorProperties annotation for constructor(s). This makes sense, in general, but may be problematic for Jackson since as of 2.8 that is equivalent to specifying @JsonCreator, which may not always be what is intended.

One thing that can help resolve issues is to add a new MapperFeature, enabled by default, that determines whether @ ConstructorProperties means same as explicit @JconCreator (enabled) or not (disabled). If not, parameter names are still available as implicit names, and explicit @JsonCreator may be used.

Note that this requires #1369 as well.

@cowtowncoder cowtowncoder changed the title Add a MapperFeature to allow disabling use of @CreatorProperties as explicit @JsonCreatore equivalent Add a MapperFeature to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Sep 14, 2016
@cowtowncoder cowtowncoder added this to the 2.9.0 milestone Sep 15, 2016
@cowtowncoder cowtowncoder changed the title Add a MapperFeature to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Add a MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Sep 15, 2016
@cowtowncoder cowtowncoder changed the title Add a MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Add MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Sep 15, 2016
@tsabirgaliev
Copy link

tsabirgaliev commented Jan 27, 2017

@cowtowncoder can this be backported to 2.8 branch? 2.9 is not yet released, and this caveat is causing headaches with Lombok, and is not very easy to identify

@cowtowncoder
Copy link
Member Author

@tsabirgaliev Unfortunately it being an API addition it can not be backported.

@electrum
Copy link

electrum commented Nov 12, 2018

The issue description and release notes seem to have a typo, as the annotation is @ConstructorProperties, not @CreatorProperties. Also, it was introduced in JDK 6, not 7.

@cowtowncoder
Copy link
Member Author

@electrum thank you, I will fix title. But as to JDK... wow. You are right, javadocs do confirm it was in JDK 6. Not sure how I misread that, but it was added in JDK 7 module.

@cowtowncoder cowtowncoder changed the title Add MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @CreatorProperties as explicit @JsonCreator equivalent Add MapperFeature.INFER_CREATOR_FROM_CONSTRUCTOR_PROPERTIES to allow disabling use of @ConstructorProperties as explicit @JsonCreator equivalent Nov 12, 2018
@electrum
Copy link

Thanks, I see you updated the tittle, but there are a couple other references in the description, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants