-
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 the bug that BlockingObservable.singleOrDefault doesn't call unsubscribe #1260
Fix the bug that BlockingObservable.singleOrDefault doesn't call unsubscribe #1260
Conversation
RxJava-pull-requests #1156 SUCCESS |
throw new IllegalArgumentException("Sequence contains too many elements"); | ||
} | ||
return result; | ||
return from(o.map(Functions.<T>identity()).singleOrDefault(defaultValue)).single(); |
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.
Why do you need to map with the identity function here?
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.
Because o is Observable<? extends T>
and I cannot call singleOrDefault(T)
on it directly.
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.
Does that mean that XXXOrDefault
have to be covariant as well :-(
public T singleOrDefault(T defaultValue)
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.
Observable<T> singleOrDefault(T defaultValue)
also need to
However, I cannot write <U super T> Observable<U> singleOrDefault(U defaultValue)
in Java :(
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 covariance stuff is insane.
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.
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.
:-)
Merge pull request #1260
BlockingObservable.singleOrDefault
doesn't callunsubscribe
when throwsIllegalArgumentException("Sequence contains too many elements")
.testSingleOrDefaultUnsubscribe
proves this bug.