Good evening team,
This is a followup of a previous PR from January 2021: https://github.com/spring-projects/spring-framework/pull/26480 . Previously it was closed with a conclusion that the change bypasses a protected method:
Given the change of protected methods I'd rather avoid this change at this stage of the 5.3.x branch.
Now that Spring 6 is coming, do you think there's a chance to add this change?
Below is the original description of the PR:
======
The REST Client exception contains a preview of the body, which is great, and it helps a lot to quickly diagnose errors.
Now, the stacktrace looks like this:
Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]
at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:101)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:238)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:147)
I'd like to add the HTTP method and URL to the error, so that the stacktrace looks like this:
Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error after GET http://localhost:49709/status/server : [no body]
at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:101)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:238)
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:147)
======
Thank you!
Comment From: jerzykrlk
Hello Rossen!
I'll resolve the conflicts then.
I haven't followed this very closely. So let me ask a silly question - is there a chance that the behaviour stays consistent across WebClient, RestTemplate and RestClient?
And one more - would you be open to more fine-tuning in the future?
Thanks!
Comment From: snicoll
Thanks very much @jerzykrlk! I've polished things up a bit to streamline thing. I've also changed the structure of the error message to be more compliant with other places in the framework. It now reads:
500 Server Error on GET request for "http://localhost:49709/status/server": [no body]
Comment From: jerzykrlk
Hello Stéphane - thanks for accepting this!