-
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
Flux.collectList() return empty list instead of emit error #3917
Comments
Hey, thanks for the report. I am wondering though - aren't you explicitly swallowing the error with |
I expected the collectList() operator always emit the error. Thus, the onErrorResume() call always return empty flux.
I don’t expect the last map flatMap(evt -> ...) block will be triggered . However, I found that the collectList() call will return an empty list occasionally… that will trigger the last map call. That is not the expected behavior.
|
[EDIT] I misinterpreted the sequence of events in my initial evaluation. The below is not really what's going on since the delay is applied to a successful termination of a [ORIGINAL] Hmmm, I think your test is rather convoluted and makes it difficult to infer what's actually going on. Let me try to explain:
With the above explanation, I'm closing the report as invalid. Hope this explanation helps you resolve the issue you are facing. |
Thanks for your updated. |
My apologies, I think I have confused something there. Your questions are very helpful and I do think you might have in fact discovered a bug that's a race condition uncovered by these events:
The situation happens to be that both Threads are draining the results at the same time and break the contract. I will also update my previous comment to reflect the reality (edit history can be viewed) as I made an error to assume the error gets delayed. The genuine signal is actually delayed and that is triggering this condition. |
Just for the record - the exclusivity of drain looks correct, so not both threads are draining at the same time. My observation came from the natural concurrency in The actual issue is that both threads attempt to complete the
There should be some handling that would drop one of the signals in case the other Thread is already handling termination. |
For a flux created by zipping two Mono MonoA and MonoB, followed by 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
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
java -version
): java 21.0.5 2024-10-15 LTSJava(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)
uname -a
): MSYS_NT-10.0-14393 wh-1eab6196ab 3.4.10-2e2ef940.x86_64 2024-07-09 21:35 UTC x86_64 MsysThe text was updated successfully, but these errors were encountered: