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:
protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
throws IOException, HttpMessageNotWritableException {
MediaType contentType = outputMessage.getHeaders().getContentType();
JsonEncoding encoding = getJsonEncoding(contentType);
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(outputMessage.getBody(), encoding);
try {
......
......
}
catch (InvalidDefinitionException ex) {
throw new HttpMessageConversionException("Type definition error: " + ex.getType(), ex);
}
catch (JsonProcessingException ex) {
throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getOriginalMessage(), ex);
}
}
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.
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.