AsyncRestTemplate changes in SPR-13413 made its harder to detect Client/Server errors [SPR-14353] #18925
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Oleg Mikhailenko opened SPR-14353 and commented
After migrating to 4.2.6 our response statuses were broken for our client side. It always showed 500 error status. It turned out our client's exception handler (
@ControllerAdvice
) caughtExecutionException
even though a server responded with 4xx/5xx error statuses.Spring's error hander for AsyncRestTemplate (
DefaultResponseErrorHandler
) contains code:It's OK but then (after #17992) any of these exceptions wrapped into
ExecutionException
inResponseExtractorFuture
(lookthrow new ExecutionException(ex);
):So as result it does not matter what error response sent by server
HttpClientErrorException/HttpServerErrorException
. It always wrapped toExecutionException
. And to fetch response status and body I have to get inner cause and cast to appropriate type. What is not so convenient.It would be great if you could change the code of
ResponseExtractorFuture
to something like:Affects: 4.2.6
Issue Links:
@ExceptionHandler
should match cause as well (e.g. for exception thrown from argument formatter)1 votes, 5 watchers
The text was updated successfully, but these errors were encountered: