Browse Source

Remove unnecessary error signal from DefaultRestClient

Before UnknownContentTypeException is thrown, it is added to the current
Observation but since UnknownContentTypeException is a
RestClientException, the exception is added again in one of the
catch blocks later on.

Closes gh-33347
pull/33365/head
Jonatan Ivanov 2 years ago committed by Stéphane Nicoll
parent
commit
6c74fee5e8
  1. 7
      spring-web/src/main/java/org/springframework/web/client/DefaultRestClient.java

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

@ -220,13 +220,10 @@ final class DefaultRestClient implements RestClient { @@ -220,13 +220,10 @@ final class DefaultRestClient implements RestClient {
return (T) messageConverter.read((Class)bodyClass, responseWrapper);
}
}
UnknownContentTypeException unknownContentTypeException = new UnknownContentTypeException(bodyType, contentType,
throw new UnknownContentTypeException(bodyType, contentType,
responseWrapper.getStatusCode(), responseWrapper.getStatusText(),
responseWrapper.getHeaders(), RestClientUtils.getBody(responseWrapper));
if (observation != null) {
observation.error(unknownContentTypeException);
}
throw unknownContentTypeException;
}
catch (UncheckedIOException | IOException | HttpMessageNotReadableException exc) {
Throwable cause;

Loading…
Cancel
Save