Skip to content
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

Mono.awaitSingleOrNull does not await completion #3487

Closed
dkhalanskyjb opened this issue Oct 18, 2022 · 0 comments
Closed

Mono.awaitSingleOrNull does not await completion #3487

dkhalanskyjb opened this issue Oct 18, 2022 · 0 comments
Assignees

Comments

@dkhalanskyjb
Copy link
Collaborator

(NB: checked the other reactive integrations, and none of them have this problem)

Mono.awaitSingleOrNull has a subtle bug: it will resume with the provided value before onComplete has happened. This leads to concurrency issues when a Publisher emits a value before actually finishing the work.

To fix such issues, we introduced awaitSingleOrNull in the past (#1993), which checked that there was, in fact, just a single element. As a side effect, it ensured that onComplete was called.

We deprecated awaitSingleOrNull for unrelated reasons and wrote a specialized implementation Mono.awaitSingleOrNull. There, this desired property was lost. We need to restore it.

The impact in a typical case where such issue does not arise should be negligible, because, as the Mono documentation states,

Most Mono implementations are expected to immediately call Subscriber.onComplete() after having called Subscriber#onNext(T).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant