Expected Behavior
When doing var sharedMono = innerMono.share(), the innerMono should not be canceled if calling sharedMono.subscribe().dispose().
At least, that's what the JavaDoc for Mono.share() suggests: It's worth noting this is an un-cancellable Subscription.
Actual Behavior
The innerMono is canceled.
Steps to Reproduce
Mono.create(monoSink -> {
monoSink.onCancel(() -> {
System.out.println("CANCELED");
});
monoSink.success("asdf");
})
.subscribeOn(Schedulers.boundedElastic())
.share()
.subscribe()
.dispose();
Thread.sleep(1000);
Prints CANCELED.
By the way, innerMono.cache().subscribe().dispose does NOT cancel innerMono, although the JavaDoc makes no statement about cancellation behavior... (just replace share() with cache() in the example.
Possible Solution
This might be a bug in the implementation or documentation, or simply me not understanding the documentation right.
Please also note that the marble diagram for share() needs a fix, too. (see its cancel() arrow)
Also, please consider documenting the cancellation behavior of cache().
Meanwhile, I will use cache() as a workaround. It might actually also make sense to document the difference between these two methods.
Thanks a lot!
Your Environment
- Reactor version(s) used: 3.4.5
- JVM version (
java -version): 14.0.1
- OS and version (eg
uname -a): MacOS 11.2.3
Expected Behavior
When doing
var sharedMono = innerMono.share(), theinnerMonoshould not be canceled if callingsharedMono.subscribe().dispose().At least, that's what the JavaDoc for
Mono.share()suggests:It's worth noting this is an un-cancellable Subscription.Actual Behavior
The
innerMonois canceled.Steps to Reproduce
Prints
CANCELED.By the way,
innerMono.cache().subscribe().disposedoes NOT cancelinnerMono, although the JavaDoc makes no statement about cancellation behavior... (just replaceshare()withcache()in the example.Possible Solution
This might be a bug in the implementation or documentation, or simply me not understanding the documentation right.
Please also note that the marble diagram for
share()needs a fix, too. (see itscancel()arrow)Also, please consider documenting the cancellation behavior of
cache().Meanwhile, I will use
cache()as a workaround. It might actually also make sense to document the difference between these two methods.Thanks a lot!
Your Environment
java -version): 14.0.1uname -a): MacOS 11.2.3