DefaultResponseErrorHandler.hasError tolerates unknown status codes

Issue: SPR-16108
This commit is contained in:
Juergen Hoeller
2017-10-24 15:44:37 +02:00
parent be5b9354a9
commit ab19c227d3
2 changed files with 26 additions and 7 deletions

View File

@@ -29,12 +29,14 @@ import org.springframework.util.FileCopyUtils;
* Spring's default implementation of the {@link ResponseErrorHandler} interface.
*
* <p>This error handler checks for the status code on the {@link ClientHttpResponse}:
* Any code with series {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} or
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR} is considered to be an
* error. This behavior can be changed by overriding the {@link #hasError(HttpStatus)} method.
* Any code with series {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}
* or {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR} is considered to be
* an error; this behavior can be changed by overriding the {@link #hasError(HttpStatus)}
* method. Unknown status codes will be ignored by {@link #hasError(ClientHttpResponse)}.
*
* @author Arjen Poutsma
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 3.0
* @see RestTemplate#setErrorHandler
*/
@@ -45,7 +47,12 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
*/
@Override
public boolean hasError(ClientHttpResponse response) throws IOException {
return hasError(getHttpStatusCode(response));
try {
return hasError(getHttpStatusCode(response));
}
catch (UnknownHttpStatusCodeException ex) {
return false;
}
}
/**