Liam Bryan opened SPR-17461 and commented
The DefaultResponseErrorHandler does not handle HttpStatus values not specified in the enum values. For example; a service we call returns 299 which reports as an error in the latest spring versions (linked code).
In previous versions (checked 4.3.14 as used in current project), this wasn't reported as an error; however the thrown UnknownHttpStatusCodeException (which is caught, and converted to false for there being an error) contained the responseBody as one of its arguments, which in turn closed the InputStream or the response meaning that the body of the response could not be parsed to a ResponseEntity anywhere.
At present, this is being gotten around with a custom class:
public final class UnrecognisedHttpStatusCodeFriendlyResponseErrorHandler extends DefaultResponseErrorHandler {
@Override
public boolean hasError(final ClientHttpResponse response) throws IOException {
try {
final HttpStatus.Series statusSeries = HttpStatus.Series.valueOf(response.getRawStatusCode());
return (HttpStatus.Series.CLIENT_ERROR.equals(statusSeries))
|| (HttpStatus.Series.SERVER_ERROR.equals(statusSeries));
} catch (final IllegalArgumentException iaEx) {
// Series was not in 1-5... Something's probably wrong...
return true;
}
}
}
Affects: 4.3.14, 5.1.2
Reference URL:
|
return (statusCode != null && hasError(statusCode)); |
Issue Links:
Liam Bryan opened SPR-17461 and commented
The
DefaultResponseErrorHandlerdoes not handleHttpStatusvalues not specified in the enumvalues. For example; a service we call returns299which reports as an error in the latest spring versions (linked code).In previous versions (checked 4.3.14 as used in current project), this wasn't reported as an error; however the thrown
UnknownHttpStatusCodeException(which is caught, and converted tofalsefor there being an error) contained theresponseBodyas one of its arguments, which in turn closed theInputStreamor theresponsemeaning that the body of the response could not be parsed to aResponseEntityanywhere.At present, this is being gotten around with a custom class:
Affects: 4.3.14, 5.1.2
Reference URL:
spring-framework/spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java
Line 52 in c2b55e6
Issue Links: