2.x Observable.combineLatestDelayError delivers Error after completion
See original GitHub issueObservable.combineLatestDelayError sends error event after complete event happened and treated as unhandled.
Checked on rx.Observable
, io.reactivex.Observable
and Flowable
@Test
public void testCombine() {
rx.observers.TestSubscriber<Integer> testSubscriber = rx.observers.TestSubscriber.create();
rx.Observable<Long> emptyObservable = rx.Observable.empty();
rx.Observable<Object> errorObservable = rx.Observable.error(new Exception());
rx.Observable.combineLatestDelayError(
Arrays.asList(
emptyObservable
.doOnEach(integerNotification -> System.out.println("emptyObservable: " + integerNotification))
.doOnTerminate(() -> System.out.println("emptyObservable: doFinally")),
errorObservable
.doOnEach(integerNotification -> System.out.println("errorObservable: " + integerNotification))
.doOnTerminate(() -> System.out.println("errorObservable: doFinally"))),
objects -> 0
)
.doOnEach(integerNotification -> System.out.println("combineLatestDelayError: " + integerNotification))
.doOnTerminate(() -> System.out.println("combineLatestDelayError: doFinally"))
.subscribe(testSubscriber);
testSubscriber.awaitTerminalEvent();
}
@Test
public void testCombine2() {
TestObserver<Integer> testObserver = TestObserver.create();
Observable<Long> emptyObservable = Observable.empty();
Observable<Object> errorObservable = Observable.error(new Exception());
Observable.combineLatestDelayError(
Arrays.asList(
emptyObservable
.doOnEach(integerNotification -> System.out.println("emptyObservable: " + integerNotification))
.doFinally(() -> System.out.println("emptyObservable: doFinally")),
errorObservable
.doOnEach(integerNotification -> System.out.println("errorObservable: " + integerNotification))
.doFinally(() -> System.out.println("errorObservable: doFinally"))),
objects -> 0
)
.doOnEach(integerNotification -> System.out.println("combineLatestDelayError: " + integerNotification))
.doFinally(() -> System.out.println("combineLatestDelayError: doFinally"))
.subscribe(testObserver);
testObserver.awaitTerminalEvent();
}
@Test
public void testCombine2Flowable() {
TestSubscriber<Integer> testObserver = TestSubscriber.create();
Flowable<Integer> emptyFlowable = Flowable.empty();
Flowable<Object> errorFlowable = Flowable.error(new Exception());
Flowable.combineLatestDelayError(
Arrays.asList(
emptyFlowable
.doOnEach(integerNotification -> System.out.println("emptyFlowable: " + integerNotification))
.doFinally(() -> System.out.println("emptyFlowable: doFinally")),
errorFlowable
.doOnEach(integerNotification -> System.out.println("errorFlowable: " + integerNotification))
.doFinally(() -> System.out.println("errorFlowable: doFinally"))),
objects -> 0
)
.doOnEach(integerNotification -> System.out.println("combineLatestDelayError: " + integerNotification))
.doFinally(() -> System.out.println("combineLatestDelayError: doFinally"))
.subscribe(testObserver);
testObserver.awaitTerminalEvent();
}
Output: testCombine
emptyObservable: [rx.Notification@2b4a2ec7 OnCompleted]
emptyObservable: doFinally
combineLatestDelayError: [rx.Notification@2b4a2ec7 OnCompleted]
combineLatestDelayError: doFinally
testCombine2
emptyObservable: OnCompleteNotification
combineLatestDelayError: OnCompleteNotification
combineLatestDelayError: doFinally
emptyObservable: doFinally
errorObservable: OnErrorNotification[java.lang.Exception]
errorObservable: doFinally
java.lang.Exception
at com.myproject.Test.testCombine2(Test.java:298)
// not really important Stacktrace
Exception in thread "main" java.lang.Exception
at com.myproject.Test.testCombine2(Test.java:298)
// repeat of not important Stacktrace
testCombine2Flowable
emptyFlowable: OnCompleteNotification
combineLatestDelayError: OnCompleteNotification
combineLatestDelayError: doFinally
emptyFlowable: doFinally
If error emitter goes first or add some timer instead of empty, then everything is ok.
Also noticed difference in events order between 1.x and 2.x. Is it correct?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Observable.combineLatest cause error after updating to ...
In the end I found a solution based on given advice above. The first thing which should be mentioned is the fact that...
Read more >Observable (RxJava Javadoc 2.2.21) - ReactiveX
Returns an Observable that emits at most a specified number of items from the source ObservableSource that were emitted in a specified window...
Read more >Observable (RxJava Javadoc 2.1.4)
Returns an Observable that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four...
Read more >io.reactivex.rxjava2/rxjava/2.2.11 : io/reactivex/Observable.java
<p> * Unlike the {@code Observable} of version 1.x, ... In this latter case, the {@code Throwable} is delivered to the global error...
Read more >The RxJava2 Default Error Handler | by Bryan Herbst - Medium
One of the design goals of 2.x was that no errors can be lost. ... if there is no subscriber that RxJava can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, it looks like the other source is not cancelled in time.
I’ve posted the fix PR as #4987 that resolves 3) and this latest case.
Yes, I’m working on the fix for 3).