Raise RestClientException for unknown status codes
HttpStatus cannot be created with an unknown status code. If a server returns a status code that's not in the HttpStatus enum values, an IllegalArgumentException is raised. Rather than allowing it to propagate as such, this change ensures the actual exception raised is a RestClientException. Issue: SPR-9406
This commit is contained in:
@@ -124,4 +124,16 @@ public class DefaultResponseErrorHandlerTests {
|
||||
|
||||
verify(response);
|
||||
}
|
||||
|
||||
// SPR-9406
|
||||
|
||||
@Test(expected=RestClientException.class)
|
||||
public void unknownStatusCode() throws Exception {
|
||||
expect(response.getStatusCode()).andThrow(new IllegalArgumentException("No matching constant for 999"));
|
||||
expect(response.getRawStatusCode()).andReturn(999);
|
||||
|
||||
replay(response);
|
||||
|
||||
handler.handleError(response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user