-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
AbstractJackson2HttpMessageConverter + Jackson 2.10: handle ValueInstantiationException properly #24455
Comments
This sounds worthwhile to me, and necessary for full Jackson 2.10 support. The only downside in catching such a new exception type is that it introduces a hard dependency on Jackson 2.10 at runtime... otherwise we'll have to work around the non-presence of that exception type through reflection. |
Jackson provides com.fasterxml.jackson.databind.cfg.PackageVersion.version(), so maybe we could check it first? |
On review, the If we decide to revisit this, we could specifically handle |
I like the approach of handling JsonMappingException. It should keep the behavior the same as it used to be with Jackson 2.9. So my vote is for interpreting JsonMappingException as HttpMessageConversionException. |
Good point about |
Wouldn't that impact applications that handle |
I'm just considering to turn a few more kinds of Jackson exception (such as |
#24499 created a PR |
In jackson-databind version 2.10 a new exception was introduced: ValueInstantiationException
It appears when we can't instantiate a new instance but successfully parsed input json.
In my case, it was null-checks in the constructor.
Previously exception which were thrown in constructor caused InvalidDefinitionException and was wrapped into HttpMessageConversionException by AbstractJackson2HttpMessageConverter:
But with a new version of jackson-databind (2.10.2, which comes with spring-boot) a new ValueInstantiationException is thrown and it is handled as a JsonProcessingException. Thereby HttpMessageNotWritableException is thrown instead (which also leads to RestClientException if it happens in RestTemplate)
I think ValueInstantiationException should cause HttpMessageConversionException and not HttpMessageNotWritableException.
The text was updated successfully, but these errors were encountered: