Skip to content

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

@jblatt1

Description

@jblatt1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions