-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
WebFlux: When using jetty-reactive-httpclient calling retry on WebClient.exchange throws CancellationException #23005
Comments
retry
on Webclient.exchange throws CancellationException
It looks like a potential https://github.com/jetty-project/jetty-reactive-httpclient issue. @scottjohnson Could you please try to reproduce using only |
@sdeleuze what I see analyzing this on the Isn't the current behavior violating Rule 2.12? In this particular case, you want to send another request, so I'd say that you have to run again through the whole process of creating a request, which would re-create new publishers, subscribers and subscriptions so that they all are different objects than the previous request (and therefore you won't see the In other words, what is the semantic of AtomicInteger unique = new AtomicInteger();
webClient.get()
.uri("http://localhost/" + unique.incrementAndGet())
.exchange()
.flatMap(r -> {
throw new ResponseStatusException(HttpStatus.OK);
})
.retry(1) Is there a request to If not, what if the first request is a In general, a call to Jetty's Thanks! |
Thanks @sbordet for weighing in. This analysis matches with our observations that the cancelled subscription was being re-used after being put in a cancelled state. @sdeleuze, we weren't able to effectively create a test on our end that reproduces using only the |
@scottjohnson I have a reproducer, below instructions. Be sure you have the dependency on spring-webflux: <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<version>5.1.8.RELEASE</version>
<scope>test</scope>
</dependency> Then the test class with this test: @Test
public void testRetry() throws Exception {
// Setup the server here.
AtomicInteger unique = new AtomicInteger();
WebClient client = WebClient.builder().clientConnector(new JettyClientHttpConnector(httpClient())).build();
client.get()
.uri(uri() + "/" + unique.incrementAndGet())
.exchange()
.flatMap(r -> {
throw new ResponseStatusException(HttpStatus.OK);
})
.retry(1)
.block();
} |
Hi, is there any progress on this issue? |
Hi, just checking in if there is any progress on this issue? Thanks! |
It looks like this was fixed as a side effect of #22375. As a result of wrapping the exchange with I confirmed that starting with 5.2 this is no longer an issue. Nevertheless I do want to follow up on the following:
The subscription for the original subscriber is indeed cancelled. However on the retry For comparison, in Reactor Netty, a cancellation is interpreted as a request to close the request, while each additional |
Thanks for all your efforts @rstoyanchev. Much appreciated! |
When using the
jetty-reactive-httpclient
client connector with WebClient, whenever we callretry
after WebClient.exchange (to retry the HTTP request), aCancellationException
is thrown instead of the request being retried. When usingreactor-netty
client, the WebClient HTTP request is retried as expected.It is unclear to us whether this is a Spring issue, or one with Reactor or Jetty. Please feel free to redirect us to the correct project.
Versions:
Spring up to 5.1.7.RELEASE
Spring Boot up to 2.1.4.RELEASE
Jetty 9.4.18.v20190429
Reactor 3.2.8.RELEASE
See this sample repository for a full demonstration of the problem: https://github.com/scottjohnson/webclient-retry-repro
In part:
We would expect this code to retry the requested URI two more times. This happens as expected when using the
reactor-netty
client.When using
jetty-reactive-http-client
, the original request is made, but on retry instead of retrying the following exception is thrown:The text was updated successfully, but these errors were encountered: