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:
Brian Clozel
2024-06-19 12:46:21 +02:00
parent 098c4b1dd7
commit f7307c9e07
2 changed files with 3 additions and 6 deletions

View File

@@ -240,19 +240,16 @@ final class DefaultRestClient implements RestClient {
ResolvableType.forType(bodyType) + "] and content type [" + contentType + "]", cause);
if (observation != null) {
observation.error(restClientException);
observation.stop();
}
throw restClientException;
}
catch (RestClientException restClientException) {
if (observation != null) {
observation.error(restClientException);
}
throw restClientException;
}
finally {
if (observation != null) {
observation.stop();
}
throw restClientException;
}
}