-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Automatic registration of Jackson parameter names module [SPR-13296] #17886
Comments
Lovro Pandžić commented Note that, due to backwards compatibility reasons, single argument constructors are recognized as delegating creators by jackson. This behavior can be overridden in this module. |
Sébastien Deleuze commented Lovro Pandžić I have 2 questions for you:
|
Lovro Pandžić commented
|
Sébastien Deleuze commented Thanks for your detailed feedback. The first point just need more tests in order to check that it introduces no regression, no blocking issue here. I am more concerned by the second point. We support registration of well known modules for JDK or widely used (Joda time for example) types, but these modules do not require any configuration, and since we do some classpath check we can register them, no problem. As soon as the module requires configuration, this is another story. We could obviously register That's why I am not 100% sure this is a good idea to automatically register Any thoughts Lovro Pandžić ? |
Lovro Pandžić commented I agree that users will be confused once they encounter this situation and I understand your concern. |
Sébastien Deleuze commented I guess it is more reasonable to put this issue in the 4.3 backlog for now, in order to see if we have users feedback, but I am not sure we will be able to introduce it later yet, since the default delegating creators behavior is default on Jackson side, and I think this is too much opinionated to change this in Spring Framework. But keep in mind that automatic registration is not a must have for all modules, and adding a module is quite easy, especially with Spring Boot, you just have to register such bean in your configuration: @Bean
Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.modulesToInstall(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
return builder;
} |
Sébastien Deleuze commented Lovro Pandžić I have updated my Latest Jackson integration improvements in Spring blog post with more information about jackson parameter names module and how to register even more easily a Jackson @Bean
public Module parameterNamesModule() {
return new ParameterNamesModule(JsonCreator.Mode.PROPERTIES);
} I also plan to update the reference documentation as well, with a mention and a link to this module (see #17990). |
Lovro Pandžić commented Thanks for feedback, blog post and documentation mentions are nice, but I do hope this issue will be resolved sometime in the future. I'll try to pursue it's solution from within jackson so this issue is resolved from my point of view. |
Sébastien Deleuze commented Ok, so I resolve this issue as "Won't fix" for now, feel free to reopen it if things evolve on Jackson side. |
Lovro Pandžić opened SPR-13296 and commented
After upgrade to jackson 2.6.0 jackson parameter names module can be used in a java 8 environment to construct classes using non default constructors for classes that have parameter names stored. For such classes default constructors can be removed and no annotations are required!
I suggest this module be added for JDK 8+ projects.
Issue Links:
1 votes, 8 watchers
The text was updated successfully, but these errors were encountered: