Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Set Jackson FAIL_ON_UNKNOWN_PROPERTIES property to false by default [SPR-11891] #16510
I've filed a ticket for that issue in Jackson itself but I thought it might be worth taking the lead here. I know changing defaults is kind of a risky thing to do but as Brian Clozel indicated in the comments of said ticket, it would actually increase resilience of already existing code.
Referenced from: commits 42aef5f
1 votes, 6 watchers
Rossen Stoyanchev commented
I agree that would be a better default. That said while it may not break existing code it could change expectations. In other words I do think there may be legitimate cases for the current default and applications relying on it.
A more subtle assumption is that currently MappingJackson2HttpMessageConverter uses a stock ObjectMapper or you can pass your own pre-configured instance. This would change that assumption since now we give an ObjectMapper configured the way we think it should be. In short I don't think the converter is a good place to make this change. If I was relying on the internal ObjectMapper and then decided to configure my own for unrelated reasons, suddenly I'd "lose" the good default(s) we provide unless I happened to notice them in the source and match them in my own ObjectMapper.
The Jackson2ObjectMapperFactoryBean where we help initialize the ObjectMapper seems a better fit for doing this since at least that default will "remain" with you for as long as you use the FactoryBean or until it's changed explicitly. I'd be okay with changing it there but otherwise propose leaving the converter as is.
Brian Clozel commented
Even though I think this configuration should be the default one in Jackson, it's true spring developers rely on the fact that our ObjectMapper configuration is the "Jackson stock configuration" and we should not mess with it.
I've created a Spring Boot issue - let's see what they think about it.