-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
status/invalidWe don't feel this issue is valid, or the root cause was found outside of ReactorWe don't feel this issue is valid, or the root cause was found outside of Reactor
Description
Expected Behavior
When a switchOnFirst function returns a single item that contains the input flux but is not derived through operators, the input flux should remain available without restriction.
Actual Behavior
The input flux is cancelled when the outer flux is cancelled (e.g. by Mono.from
), making it unusable.
Steps to Reproduce
public static void main(String[] args) {
Flux<String> input = Flux.just("foo", "bar");
Mono<Flux<String>> nested = Mono.from(input.switchOnFirst((first, all) -> Mono.just(all)));
Flux<String> item = nested.block();
System.out.println(item); // prints SwitchOnFirstMain as expected
System.out.println(item.collectList().block()); // never terminates as the item has been cancelled
}
Possible Solution
In the above example, Mono.from sees the onNext immediately, and cancels the FluxSwitchOnFirst. Cancelling FluxSwitchOnFirst however also cancels the SwitchOnFirstMain, which it should not. Cancellation should only be sent to the publisher returned by the switchOnFirst lambda (in this case the Mono.just)
Your Environment
- Reactor version(s) used: 3.6.9
- Other relevant libraries versions (eg.
netty
, ...): N/A
Metadata
Metadata
Assignees
Labels
status/invalidWe don't feel this issue is valid, or the root cause was found outside of ReactorWe don't feel this issue is valid, or the root cause was found outside of Reactor