Skip to content

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

@helmut-hackl-dynatrace

Description

@helmut-hackl-dynatrace

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 the getBody() 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions