Test to demonstrate an apparent problem (or possibly a misunderstanding of mine) with Reactor's Flux.mergeSequential()
./gradlew build
The unit test is run automatically with the build and may also be run via:
./gradlew test
In the event that Flux.mergeSequential(Publisher<? extends I>... sources) is invoked with a group of Producers (mono1
, mono2
, ..., monoN
, monoFinal
) for which the earlier ones are waiting on a signal from the last one, it appears that the last one is never executed, and thus the first N never complete.
The test class demonstrating this is MergeSequentialUnitTest
which has three test methods in it:
- test_mergeSequential_failsWhenDelayed: Demonstrates the error case.
- test_mergeSequential_succeedsWhenNotDelayed: Demonstrates that all Producers complete if the initial producers are not dependent on the last producer to complete.
- test_mergeSequential_succeedsWhenDelayedWithDoOnSubscribeWorkaround: Demonstrates the workaround of applying Mono.doOnSubscribe(Consumer<? super Subscription> onSubscribe) to
monoFinal
. (Mono.log() works as well.)
The test code is currently configured to run with Reactor 3.6.5 which does not work. The [build.gradle.kts] also includes commented lines for Reactor 3.5.0 (first version I found that does not work) and Reactor 3.4.37 (last version that does work).