Skip to content

Commit c72e31b

Browse files
committed
Merge branch '6.1.x'
2 parents ce49354 + f7307c9 commit c72e31b

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,16 @@ private <T> T readWithMessageConverters(ClientHttpResponse clientResponse, Runna
247247
ResolvableType.forType(bodyType) + "] and content type [" + contentType + "]", cause);
248248
if (observation != null) {
249249
observation.error(restClientException);
250+
observation.stop();
250251
}
251252
throw restClientException;
252253
}
253254
catch (RestClientException restClientException) {
254255
if (observation != null) {
255256
observation.error(restClientException);
256-
}
257-
throw restClientException;
258-
}
259-
finally {
260-
if (observation != null) {
261257
observation.stop();
262258
}
259+
throw restClientException;
263260
}
264261
}
265262

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class RestClientObservationTests {
7373

7474
@BeforeEach
7575
void setupEach() {
76-
7776
this.client = RestClient.builder()
7877
.messageConverters(converters -> converters.add(0, this.converter))
7978
.requestFactory(this.requestFactory)
@@ -267,6 +266,7 @@ private void mockResponseBody(String expectedBody, MediaType mediaType) throws E
267266

268267

269268
private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
269+
TestObservationRegistryAssert.assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
270270
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
271271
.hasObservationWithNameEqualTo("http.client.requests").that();
272272
}

0 commit comments

Comments
 (0)