Closed
Description
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