-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
(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).