Skip to content

Commit 17140c8

Browse files
committed
Polish contribution
See gh-24595
1 parent 2fb13d4 commit 17140c8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

spring-web/src/main/java/org/springframework/web/client/DefaultResponseErrorHandler.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -103,9 +103,8 @@ public void handleError(ClientHttpResponse response) throws IOException {
103103
HttpStatus statusCode = HttpStatus.resolve(response.getRawStatusCode());
104104
if (statusCode == null) {
105105
byte[] body = getResponseBody(response);
106-
String message = getErrorMessage(
107-
response.getRawStatusCode(), response.getStatusText(),
108-
body, getCharset(response));
106+
String message = getErrorMessage(response.getRawStatusCode(),
107+
response.getStatusText(), body, getCharset(response));
109108
throw new UnknownHttpStatusCodeException(message,
110109
response.getRawStatusCode(), response.getStatusText(),
111110
response.getHeaders(), body, getCharset(response));

spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -183,6 +183,7 @@ public void handleErrorForCustomClientError() throws Exception {
183183
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
184184
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
185185
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
186+
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
186187
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
187188
}
188189

@@ -222,6 +223,7 @@ public void handleErrorForCustomServerError() throws Exception {
222223
assertThat(actualUnknownHttpStatusCodeException.getRawStatusCode()).isEqualTo(statusCode);
223224
assertThat(actualUnknownHttpStatusCodeException.getStatusText()).isEqualTo(statusText);
224225
assertThat(actualUnknownHttpStatusCodeException.getResponseHeaders()).isEqualTo(headers);
226+
assertThat(actualUnknownHttpStatusCodeException.getMessage()).contains(responseBody);
225227
assertThat(actualUnknownHttpStatusCodeException.getResponseBodyAsString()).isEqualTo(responseBody);
226228
}
227229

@@ -241,6 +243,7 @@ public void bodyAvailableAfterHasErrorForUnknownStatusCode() throws Exception {
241243
assertThat(StreamUtils.copyToString(response.getBody(), StandardCharsets.UTF_8)).isEqualTo("Hello World");
242244
}
243245

246+
244247
private static class TestByteArrayInputStream extends ByteArrayInputStream {
245248

246249
private boolean closed;

0 commit comments

Comments
 (0)