Avoid recording RestClient observations twice
Prior to this commit, the fix for gh-32575 introduced cases where the client observation would be stopped twice. This commit ensures that `RestClient` observations are stopped only once when the response is closed, or before throwing an unhanlded exception. Fixes gh-33068
This commit is contained in:
@@ -73,7 +73,6 @@ class RestClientObservationTests {
|
||||
|
||||
@BeforeEach
|
||||
void setupEach() {
|
||||
|
||||
this.client = RestClient.builder()
|
||||
.messageConverters(converters -> converters.add(0, this.converter))
|
||||
.requestFactory(this.requestFactory)
|
||||
@@ -267,6 +266,7 @@ class RestClientObservationTests {
|
||||
|
||||
|
||||
private TestObservationRegistryAssert.TestObservationRegistryAssertReturningObservationContextAssert assertThatHttpObservation() {
|
||||
TestObservationRegistryAssert.assertThat(this.observationRegistry).hasNumberOfObservationsWithNameEqualTo("http.client.requests",1);
|
||||
return TestObservationRegistryAssert.assertThat(this.observationRegistry)
|
||||
.hasObservationWithNameEqualTo("http.client.requests").that();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user