spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.35k stars 38.03k forks source link

Please check usage of ResourceAccessException vs. RestClientException wrapping IOException in DefaultRestClient #33464

Open helmut-hackl-dynatrace opened 1 month ago

helmut-hackl-dynatrace commented 1 month ago

Affects: spring web 6.1.11

it's not really clear when a ResourceAccessException (wrapping an IOException) or its base class RestClientException (which can also wrap an IOException) is thrown in org.springframework.web.client.DefaultRestClient.

eg. when calling responseWrapper.hasEmptyMessageBody()in readWithMessageConverters and thegetBody() call to an underlying ReactorNettyClientResponse does timeout (wrapped into an IOException) - i would expect a ResourceAccessException.

 /**
 * Exception thrown when an I/O error occurs.
 *
 * @author Arjen Poutsma
 * @since 3.0
 */
public class ResourceAccessException extends RestClientException {

from stacktrace:

2024-09-02 03:46:34.003 UTC WARN [svm25641,dynatrace.launcher] [qtp242113956-122375] ClusterAppManifestsFetcherImpl: Cannot fetch app icon from cluster endpoint https://svm25641.apps.internal.dynatrace.com/platform-internal/cluster-internal/manifest/dynatrace.classic.databases/icon
org.springframework.web.client.RestClientException: Error while extracting response for type [org.springframework.core.io.Resource] and content type [image/png]
    at org.springframework.web.client.DefaultRestClient.readWithMessageConverters(DefaultRestClient.java:240)
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.readBody(DefaultRestClient.java:685)
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.toEntityInternal(DefaultRestClient.java:655)
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.toEntity(DefaultRestClient.java:644)
Caused by: java.io.IOException: null
    at org.springframework.http.client.ReactorNettyClientRequest.convertException(ReactorNettyClientRequest.java:143)
    at org.springframework.http.client.ReactorNettyClientResponse.getBody(ReactorNettyClientResponse.java:87)
    at org.springframework.web.client.DefaultRestClient$DefaultConvertibleClientHttpResponse.getBody(DefaultRestClient.java:748)
    at org.springframework.web.client.IntrospectingClientHttpResponse.hasEmptyMessageBody(IntrospectingClientHttpResponse.java:83)
    at org.springframework.web.client.DefaultRestClient.readWithMessageConverters(DefaultRestClient.java:203)
    ... 176 common frames omitted
Caused by: io.netty.handler.timeout.ReadTimeoutException: null
rstoyanchev commented 1 week ago

I think ResourceAccessException is about early I/O issues that result from request execution, and that does not include I/O errors from handling the response.

spring-projects-issues commented 4 days ago

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.