-
Notifications
You must be signed in to change notification settings - Fork 564
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
Single onCancel and OnComplete fixes #1814
Conversation
Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unsatisfactory change.
If a 5-minute drive-by review finds 3 issues, what else is lurking?
What makes the rewrite of the entire CompletableFuture
necessary in the first place? Its operation and contract is subtle.
Type-wise problem:
Default Single.onCancel
creates a new Single
and was probably designed for builder-like flowing style. A subtype of Single
now mutates this
. Case in point: the very invocation of single.onCancel
from inside onSubscribe
is invalid; it only works as long as Single.from
returns a specific subtype of Single
. When that changes, this implementation will be broken and you will never find out why.
Atomicity:
On at least one path multiple things are modified, but not atomically. This is going to create problems in valid use cases. Case in point: multiple Subscriber
will be created and subscribed, and will not make any progress, thus breaking the reactive spec that the Subscriber
s eventually either cancel
or request
.
Deferred action:
Cancellation is deferred until onCancel
is registered. (Ok, this one is addressed)
In order to justify a deep analysis of the change (#1664), I would like to see a justification for a rewrite in that pull request.
Why did we rewrite
|
Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
…issing onComplete callbacks Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How could it have "missed" onComplete
? It cannot transition to any new state after super.complete
, even if upstream decides to onError
. Besides, the atomic getAndSet
will transition to yet another state where the onComplete
is futile, even if observed.
@olotenko There is no |
So? |
|
You've just shown yet another problem with this design where both Requesting cancellation is legitimate. Anyone who has access to The problem with me enumerating what can go wrong is that it seems the specific symptoms get addressed, not the underlying design problem. |
Thx @olotenko for finding the issue
Signed-off-by: Daniel Kec daniel.kec@oracle.com