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

"multiple subscribers not supported" when using WebClient exchange #32727

Closed
poutsma opened this issue Apr 29, 2024 · 2 comments
Closed

"multiple subscribers not supported" when using WebClient exchange #32727

poutsma opened this issue Apr 29, 2024 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@poutsma
Copy link
Contributor

poutsma commented Apr 29, 2024

With Jetty Reactive Client 4.0.2+, subscribing to a publisher multiple times results in test timeouts. To get rid of those, we introduced guards against multiple subscriptions in 6.1.4, see #32100, after a suggestion from the Jetty team (see jetty-project/jetty-reactive-httpclient#354 (comment)).

This guard was backported to 6.0.17 (see #32102), and 5.0.3.32 (see #32101). However, it seems that this change is causing issues on 6.0.x (and potentially also 5.3.x) when used in combination with WebClient's exchange method, for instance:

		Mono<String> responseEntityMono = webClient
				.post().uri("http://localhost:8081")
				.exchangeToMono( response -> response.bodyToMono(String.class))

Specifically, this code results in an IllegalStateException thrown here: https://github.com/jetty-project/jetty-reactive-httpclient/blob/3.0.x/src/main/java/org/eclipse/jetty/reactive/client/internal/AbstractSinglePublisher.java#L49.
The error is only logged, and can safely be ignored. However, it does potentially spam the log, so should be fixed.

The cause of this problem is unclear. However, removing the aforementioned guard resolved it. See #32727 (comment)

Since the original issue (#32100) only occurred with Jetty Reactive Client 4.0.2+, it appears that we can remove the guard in 6.0.x (using Jetty Reactive Client 3.0.x) and 5.3.x (JRC 1.1.x), and only keep them in 6.1.x and higher.

@poutsma poutsma added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression labels Apr 29, 2024
@poutsma poutsma added this to the 6.0.20 milestone Apr 29, 2024
@poutsma poutsma self-assigned this Apr 29, 2024
@poutsma poutsma added the for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x label Apr 29, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-5.3.x Marks an issue as a candidate for backport to 5.3.x labels Apr 29, 2024
@poutsma
Copy link
Contributor Author

poutsma commented Apr 29, 2024

After doing more investigation, it seems that the issue does not occur with Spring Framework 5.3.x, only 6.0.17+. We therefore do not need to back port. See below.

@poutsma poutsma changed the title Revert guard against multiple body subscriptions for Jetty Reactive Client < 4.x "multiple subscribers not supported" when using WebClient exchange Apr 30, 2024
@poutsma
Copy link
Contributor Author

poutsma commented Apr 30, 2024

The reason for the IllegalStateException from Jetty appears to be that Flux::onSubscribe cannot be used to block a subscription, and that was the mechanism used by the AbstractClientHttpResponse. Why the behavior was only triggered by Jetty Reactive Client 3 is unclear.

The original guard against multiple subscriptions is issue #32100, which was fixed in 6.1.x and backported to 6.0.x and 5.3.x. The fix for this issue should be backported to the same branches, despite my earlier comments.

@poutsma poutsma modified the milestones: 6.0.20, 6.1.7 Apr 30, 2024
@poutsma poutsma added for: backport-to-6.0.x Marks an issue as a candidate for backport to 6.0.x type: bug A general bug and removed status: backported An issue that has been backported to maintenance branches type: regression A bug that is also a regression labels Apr 30, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.0.x Marks an issue as a candidate for backport to 6.0.x labels Apr 30, 2024
poutsma added a commit that referenced this issue Apr 30, 2024
This commit changes the guard against multiple subscriptions, as the
previously used doOnSubscribe hook could not function as guard in
certain scenarios.

See gh-32727
Closes gh-32728
poutsma added a commit that referenced this issue Apr 30, 2024
This commit changes the guard against multiple subscriptions, as the
previously used doOnSubscribe hook could not function as guard in
certain scenarios.

See gh-32727
Closes gh-32732
poutsma added a commit that referenced this issue Apr 30, 2024
This commit changes the guard against multiple subscriptions, as the
previously used doOnSubscribe hook could not function as guard in
certain scenarios.

Closes gh-32727
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) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant