Closed
Description
Jerzy Krolak opened SPR-17130 and commented
The default RestTemplate
HTTP error exceptions might contain some preview of the response body, along with the HTTP status code.
So that, instead of this:
org.springframework.web.client.HttpClientErrorException.BadRequest: 400 Bad Request
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
... I could see this:
org.springframework.web.client.HttpClientErrorException.BadRequest: 400 Bad Request [<html><head><title>page not found</title>...]
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
or even this:
org.springframework.web.client.HttpClientErrorException.Conflict: 409 Conflict [{
"error": {
"errors": [
{
"domain": "global",
"reason": "conflict",
"message": "You already own this bucket. Please select another name."
}
],
"code": 409,
"message": "You already own this bucket. Please select another name."
}
}]
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
This should not introduce too much overhead, as the response is already there, in byte [] body
.
Affects: 5.0.8
Issue Links:
- Exception hierarchy under HttpClientException and HttpServerException for the RestTemplate [SPR-15404] #19967 Exception hierarchy under HttpClientException and HttpServerException for the RestTemplate
Referenced from: pull request #1956