Skip to content
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

Merged
merged 1 commit into from
May 27, 2014

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented May 25, 2014

BlockingObservable.singleOrDefault doesn't call unsubscribe when throws IllegalArgumentException("Sequence contains too many elements"). testSingleOrDefaultUnsubscribe proves this bug.

@cloudbees-pull-request-builder

RxJava-pull-requests #1156 SUCCESS
This pull request looks good

throw new IllegalArgumentException("Sequence contains too many elements");
}
return result;
return from(o.map(Functions.<T>identity()).singleOrDefault(defaultValue)).single();
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Contributor

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)

Copy link
Member Author

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 :(

Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

benjchristensen added a commit that referenced this pull request May 27, 2014
@benjchristensen benjchristensen merged commit a34cba2 into ReactiveX:master May 27, 2014
@zsxwing zsxwing deleted the bo-singleOrDefault-bug branch May 27, 2014 09:41
@benjchristensen benjchristensen mentioned this pull request Jun 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants