You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RestTemplate.handleResponse calls ResponseErrorHandler.hasError(response) to check if it should delegate error handling to ResponseErrorHandler instance.
In case of an unknown status code, DefaultResponseErrorHandler.hasError swallows the exception thrown by DefaultResponseErrorHandler.getHttpStatusCode(response) and returns false.
This causes RestTemplate code to proceed with standard response handling, but without possibility to read message body, which has already been consumed during UnknownHttpStatusCodeException creation in DefaultResponseErrorHandler.getHttpStatusCode(response) call.
I also faced difficulties with unknown status codes. We have some logic based on catching and processing RestClientResponseException, especially it's subclass - UnknownHttpStatusCodeException. But in 4.3.12 new approach was introduced, so we can't even get response data w/o providing custom ResponseErrorHandler. Maybe it would be better to make hasError() method work the same way as it works in Spring Framework 5. I've submitted pull request which is able to resolve this issue. I hope this will help. #1742
Milos Cubrilo opened SPR-16604 and commented
RestTemplate.handleResponse
callsResponseErrorHandler.hasError(response)
to check if it should delegate error handling toResponseErrorHandler
instance.In case of an unknown status code,
DefaultResponseErrorHandler.hasError
swallows the exception thrown byDefaultResponseErrorHandler.getHttpStatusCode(response)
and returnsfalse
.This causes
RestTemplate
code to proceed with standard response handling, but without possibility to read message body, which has already been consumed duringUnknownHttpStatusCodeException
creation inDefaultResponseErrorHandler.getHttpStatusCode(response)
call.Affects: 4.3.14
Issue Links:
Referenced from: pull request #1742, and commits 3b3f27d, d95bbb6
The text was updated successfully, but these errors were encountered: