Skip to content

HttpMessageConverterExtractor should wrap HttpMessageNotReadableException in RestClientExceptions [SPR-13592] #18170

Closed
@spring-projects-issues

Description

@spring-projects-issues

Kristoffer Peterhänsel opened SPR-13592 and commented

When using a RestTemplate instance within a Spring MVC application, client exceptions may propagate in the MVC stack and can be wrongly mapped by server ExceptionHandlers, leading to a wrong HTTP response sent to the browser sending a request to the MVC application.

The RestTemplate instance uses HttpMessageConverter to decode the remote service responses; and when those fail decoding an HTTP response, they can throw an HttpMessageNotReadableException. That exception then bubbles up through the HttpMessageConverterExtractor, RestTemplate and the whole MVC stack, later mapped to HTTP 400 responses, since those exceptions can also be throws by the server stack when the incoming requests can't be deserialized.

Such exceptions should be nested under a RestClientException to avoid erroneous server responses and confusing situations for developers.


Affects: 4.1.5

Issue Links:

Referenced from: commits 81143a8, b84fefc

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions