Skip to content

Commit 873c9fe

Browse files
committed
Merge branch '6.1.x'
2 parents 67838f3 + 36e84a5 commit 873c9fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private <T> T readWithMessageConverters(ClientHttpResponse clientResponse, Runna
204204

205205
MediaType contentType = getContentType(clientResponse);
206206

207-
try (clientResponse) {
207+
try {
208208
callback.run();
209209

210210
IntrospectingClientHttpResponse responseWrapper = new IntrospectingClientHttpResponse(clientResponse);
@@ -257,17 +257,18 @@ else if (messageConverter.canRead(bodyClass, contentType)) {
257257
ResolvableType.forType(bodyType) + "] and content type [" + contentType + "]", cause);
258258
if (observation != null) {
259259
observation.error(restClientException);
260-
observation.stop();
261260
}
262261
throw restClientException;
263262
}
264263
catch (RestClientException restClientException) {
265264
if (observation != null) {
266265
observation.error(restClientException);
267-
observation.stop();
268266
}
269267
throw restClientException;
270268
}
269+
finally {
270+
clientResponse.close();
271+
}
271272
}
272273

273274
private static MediaType getContentType(ClientHttpResponse clientResponse) {

0 commit comments

Comments
 (0)