Skip to content

2.x: firstOrError call on dispose twice #6268

Closed
@ibaca

Description

@ibaca

In RxJava (2.2.2) if I use the next code the onDispose callback is called twice. I have already changed the code to not use this approach bc the s.onNext inside the subscribe is pretty obscure, but I report it just in case this can affect more cases. Looks like firstOrError (actually ObservableElementAtSingle) can call upstream cancelation twice.

Code that produces the problem:

BehaviorSubject<Integer> s = BehaviorSubject.create();
s.doOnLifecycle(d -> out.println("subscribe"), () -> { out.println("dispose"); s.onNext(2); })
        .firstOrError().subscribe().dispose();

Console output:

subscribe
dispose
dispose

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions