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

Flowable.singleOrError() does not signal an exception if followed by flatMapPublisher #5903

Closed
jblatt1 opened this issue Mar 8, 2018 · 1 comment · Fixed by #5904
Closed
Milestone

Comments

@jblatt1
Copy link

jblatt1 commented Mar 8, 2018

The following code demonstrates the expected behavior of Flowable.singleOrError() (as I understand it):

Flowable.empty()
    .singleOrError()
    .blockingGet(); // NoSuchElementException is thrown, as expected

However, if singleOrError() is immediately followed by Single.flatMapPublisher(...), the exception is lost:

Flowable.empty()
    .singleOrError()
    .flatMapPublisher(Flowable::just)
    .blockingSubscribe(); // No exception is thrown

Strangely, if anything is done between Flowable.singleOrError() and Single.flatMapPublisher(...), the exception is thrown as expected:

Flowable.empty()
    .singleOrError()
    .map(x -> x)
    .flatMapPublisher(Flowable::just)
    .blockingSubscribe(); // NoSuchElementException is thrown, as expected

This is with RxJava 2.1.10 and Reactive Streams 1.0.2.

@akarnokd
Copy link
Member

akarnokd commented Mar 8, 2018

Thanks for reporting and sharing code to reproduce the issue. The bug is in singleOrError triggered by a conversion back to toFlowable. Fix posted in #5904.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants