-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Mono.share() allow a stream to be canceled #3740
Comments
Hello, @rgarciapariente 👋 I am not sure that I follow. The first example looks correct
This goes according to the javadoc:
The second example has only one subscriber, which cancels itself upon timeout. However, meanwhile, the result is delivered from the source to the subscription – which is not cancelled, and can be used again by late subscribers. To me it looks as if the behaviour is correct. Can you please explain what seems to be the incorrect behaviour? |
Ah. I think I understand what you mean. You're referring to the fact that the source is being reached twice - that the "Learning to say hi: Hola" is printed out twice. Am I correct? That doesn't mean cancellation I believe, but potentially re-subscribing to the source. Is that the actual issue? |
Many thanks for your fast answer :) yes, that is. I am interpreting of javadoc "It's worth noting this is an un-cancellable" as meaning that "Learning to say hi: Hello" should not be executed twice in the first sample |
I see. Well, this is quite interesting. Indeed, the upstream subscription gets cancelled in case all downstream subscribers are gone. A recent change: #2756. Background: #2680 -> the same reasoning as you brought up. It makes sense to me after looking into the background and the implementation. The current behaviour sounds like something expected. The issue I see now is the misleading documentation. As you can see in the PR, all other javadocs have been aligned, except this one. Probably an omission. I'll mark this issue as a documentation problem. Is that ok for you @rgarciapariente ? |
Similarly to Flux#share, Mono#share also cancels the source when all Subscribers have cancelled. This change improves the documentation. Following #2680 and #2756 there exists a misalignment in the javadoc for Mono#share method. Since cancelling the source is a fact, the javadoc is now improved instead of changing the behaviour. Resolves #3740
Similarly to Flux#share, Mono#share also cancels the source when all Subscribers have cancelled. This change improves the documentation. Following #2680 and #2756 there exists a misalignment in the javadoc for Mono#share method. Since cancelling the source is a fact, the javadoc is now improved instead of changing the behaviour. Resolves #3740
I understand and share your argument. Thank you very much for your time |
We are using
Mono::share
and if the mono recive a TimeOut exception the mono execution is canceledExpected Behavior
I expect that a timeout don't cancel a Mono return by share() method.
Actual Behavior
The mono is cancelled
Steps to Reproduce
Result:
Note the two "Learning to say ...."
but
Result:
Your Environment
java -version
): Java version: 17.0.4, vendor: GraalVM Community,The text was updated successfully, but these errors were encountered: