-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Fix to future cancellation #1267
Fix to future cancellation #1267
Conversation
1) Creating an Observable from an already-cancelled Future should emit nothing (equivalent to Observable.never()) (it currently emits onError(CancellationException) 2) Creating an Observable from a Future then unsubscribeing immediately before Future.get() unblocks should be an Observable.never(). This test already passes.
Mmm, not sure if that is better. I think it makes more sense to call |
RxJava-pull-requests #1161 SUCCESS |
My understanding of the Rx contract was that an outer unsubscribe should cause downstream emissions to stop whenever possible. I encountered a case where |
I think the question is more about the semantics of In .NET (pseudo notation where
whereas (using 18.3, for samples I stick to the released version, may be changed in master since there were a lot of changes to zip) this returns
So there is definitively a difference here, but in any case I'd separate that from |
The CancelationException is not a real error. Its more of an onComplete because it is the only way the |
I agree with @abersnaze. I don't find it intuitive that calling
|
@@ -62,6 +62,10 @@ public void call() { | |||
} | |||
})); | |||
try { | |||
//don't block or propagate CancellationException if already unsubscribed | |||
if (subscriber.isUnsubscribed()) { |
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.
Agreed on this statement.
The catch
could still result in an exception being thrown and unsubscribe
having happened because it is a race. So we likely need a check inside the catch as well.
An |
RxJava-pull-requests #1177 SUCCESS |
Can you please rebase this so it can be merged? It conflicts now. |
Done in #1291 |
Right now, Observable.from(Future f) emits onError(CancellationException) when f starts out in a cancelled state. This change makes Observable.from(f) emit nothing at all.