Completion event fires before subscription event for empty Multi #1663
Unanswered
julianhowarth
asked this question in
Q&A
Replies: 1 comment 5 replies
-
I need to check this 😃 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm slightly confused that most of the time, the completion event on a Multi fires after the subscription event has handled any callback. However, when there are no items, and the subscription callback is waiting on something, then the completion event gets fired before the subscription event callback is finished. This can be demonstrated just by switching the subscription event thread.
produces expected output:
But switching to an empty Stream:
gives:
I was expecting to see the same ordering in both cases i.e. that the completion event will not be fired until the subscription callback is complete. If this is the intended behaviour then I think it would be helpful for it to be called out prominently in the documentation.
On a related note, I think it would also be helpful to call out that the subscription callback event is called after the supplier of items to the Multi i.e. that although evaluation of the supplier is deferred until subscription, it is not deferred until after the return of the
onSubscription
event.Above is running on mutiny 2.6.2 with Java 21.0.4
Beta Was this translation helpful? Give feedback.
All reactions