Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception mapping does not work as expected when plugging in ReactorNettyClientRequestFactory into RestTemplate and RestClient #32952

Closed
helmut-hackl-dynatrace opened this issue Jun 4, 2024 · 5 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@helmut-hackl-dynatrace
Copy link

helmut-hackl-dynatrace commented Jun 4, 2024

Affects: Spring Framework Web 6.1.8

I use the ReactorNettyClientRequestFactory within RestTemplate and RestClient.
RestTemplate and RestClient take care of mapping IOExceptions to ResourceAccessExceptions.

In case of using the reactor.netty.http.client.HttpClient, ReactorNettyClientRequest, ReactorNettyClientResponse -
RuntimeExceptions like IllegalStateException (caused by .block() calls), io.netty.handler.timeout.ReadTimeoutException etc. bubble thru - up to RestTemplate and RestClient consumers which should only know the RessoureAccessExceptions.
So most likely IOExceptions should be thrown in ReactorNettyClientRequest, ReactorNettyClientResponse methods.

Furthermore the behaviour is not consistent with other ClientHttpRequestFactory implementations
like JettyClientHttpRequestFactory, OkClientHttpRequestFactory, ...

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 4, 2024
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 4, 2024
@jhoeller jhoeller self-assigned this Jun 4, 2024
@jhoeller jhoeller added this to the 6.1.9 milestone Jun 4, 2024
jhoeller added a commit that referenced this issue Jun 4, 2024
@jhoeller
Copy link
Contributor

jhoeller commented Jun 4, 2024

A revision will be available in the upcoming 6.1.9 snapshot, consistently converting to IOExceptions. Feel free to give it an early try!

@helmut-hackl-dynatrace
Copy link
Author

big thanks! i will give it a try ...

@helmut-hackl-dynatrace
Copy link
Author

I patched your changes for testing - looks ok. thanks again.

@helmut-hackl-dynatrace
Copy link
Author

helmut-hackl-dynatrace commented Jun 20, 2024

one update:

in
your fix

you throw in ReactorNettyClientRequest::convertException - after falling thru - the IOException this way:

return new IOException(ex.getMessage(), cause);

In case of eg. a io.netty.handler.timeout.ReadTimeoutException both are null - the message plus the cause.
So you loose the connex to ex and that it was a timeout that caused the exception.

Consumers like org.springframework.web.client.DefaultRestClient.DefaultRequestBodyUriSpec#createResourceAccessException
don't have this information at hand and throw a ResourceAccessException with "null" message.

@jhoeller
Copy link
Contributor

Good point! Revised for 6.1.11 in #33080, including the original exception if there is no cause now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants