-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
type/bugA general bugA general bug
Milestone
Description
For a flux created by zipping two Mono MonoA and MonoB, followed by collectList(),
Flux.zip(MonoA, MonoB).collectList()
If MonoB emit error, the collectList() operator should emit the error instead of return a empty list.
Expected Behavior
Flux.collectList() should emit the error emitted by MonoB.
Actual Behavior
Sometime Flux.collectList() will return empty list instead of emit the error.
Steps to Reproduce
Here is a unit test to reproduce the issue
@Test
public void bug_Test() {
final var numItem = 1000000;
var fluxToTest = Flux.range(1, numItem)
.flatMap(ignored -> {
var mono1 = Mono.empty()
.publishOn(PARALLEL_SCHEDULER) // would pass the test if not run in parallel scheduler
.map(Optional::of)
.defaultIfEmpty(Optional.empty());
var mono2 = Mono.error(new NullPointerException())
.map(Optional::of)
.defaultIfEmpty(Optional.empty());
return Flux.zip(mono1, mono2).collectList().onErrorResume(e -> Mono.empty());
})
// expect upstream will emit error signal only
.flatMap(evt ->
Mono.error(new RuntimeException("Unexpected empty list return by collectList of size %s".formatted(evt.size())))
);
StepVerifier.create(fluxToTest).expectNextCount(0).verifyComplete();
}The above test always failed with empty list emitted in the last flatMap() block. For expect behavior, the onErrorResume() operator would replace all error signal into Mono.empty and no data would be processed by the last flatMap() block.
Possible Solution
Your Environment
- Reactor version(s) used: 3.6.9
- JVM version (
java -version): java 21.0.5 2024-10-15 LTS
Java(TM) SE Runtime Environment (build 21.0.5+9-LTS-239)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.5+9-LTS-239, mixed mode, sharing) - OS and version (eg
uname -a): MSYS_NT-10.0-14393 wh-1eab6196ab 3.4.10-2e2ef940.x86_64 2024-07-09 21:35 UTC x86_64 Msys
Metadata
Metadata
Assignees
Labels
type/bugA general bugA general bug