Affects: Spring Boot 2.2.5
More specifically spring-web 5.2.4
Scenario
Assume a bean definition with Lombok annotations used for annotation, for instance:
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
import java.util.Map;
@Value
@Builder
public class InformationReceivedRequest {
@NonNull
private String informationType;
private Map<String, Object> data;
}
when making a JSON request with null as informationType, Jackson fails to create the corresponding object due to the non-null restriction, creating a ValueInstantiationException. This exception extends JsonMappingException, which extends JsonProcessingException.
In spring-web 5.2.3, class AbstractJackson2HttpMessageConverter would convert any JsonProcessingException to HttpMessageNotReadableException. This second exception is then treated at DefaultHandlerExceptionResolver (part of spring-webmvc), and transformed into a 400 BAD REQUEST response.
However, in spring-web 5.2.4, the class AbstractJackson2HttpMessageConverter has been modified so as to convert JsonMappingException into HttpMessageConversionException. This exception is not covered by DefaultHandlerExceptionResolver, which means the exception bubbles up to produce a 500 INTERNAL ERROR response.
This means that the same ValueInstantiationException that used to result in a 400 BAD REQUEST response (as expected), now results in a 500 INTERNAL ERROR response.
Affects: Spring Boot 2.2.5
More specifically spring-web 5.2.4
Scenario
Assume a bean definition with Lombok annotations used for annotation, for instance:
when making a JSON request with
nullasinformationType, Jackson fails to create the corresponding object due to the non-null restriction, creating aValueInstantiationException. This exception extendsJsonMappingException, which extendsJsonProcessingException.In spring-web 5.2.3, class
AbstractJackson2HttpMessageConverterwould convert anyJsonProcessingExceptiontoHttpMessageNotReadableException. This second exception is then treated atDefaultHandlerExceptionResolver(part of spring-webmvc), and transformed into a400 BAD REQUESTresponse.However, in spring-web 5.2.4, the class
AbstractJackson2HttpMessageConverterhas been modified so as to convertJsonMappingExceptionintoHttpMessageConversionException. This exception is not covered byDefaultHandlerExceptionResolver, which means the exception bubbles up to produce a500 INTERNAL ERRORresponse.This means that the same
ValueInstantiationExceptionthat used to result in a400 BAD REQUESTresponse (as expected), now results in a500 INTERNAL ERRORresponse.