You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this intentional or a bug. The following code:
packageTest;
importio.reactivex.Observable;
importio.reactivex.schedulers.Schedulers;
importio.reactivex.Single;
publicclassTest {
publicstaticvoidmain(String[] args) {
// Observable.just(0,1) // UndeliverableException - First concatMapSingle-block throws, interrupting second oneObservable.just(2, 0) // Just "MyError" output, exception in first block appears to vanish
.concatMapSingle(workItem2 -> {
returnSingle.just(workItem2).subscribeOn(Schedulers.computation()).map(workItem -> {
try {
Thread.sleep(1000);
if (workItem == 1)
thrownewException("Something in first block failed");
Thread.sleep(1000);
} catch (InterruptedExceptione) {
System.out.println("InterruptedException in block 1");
throwe;
}
returnworkItem;
});
}).concatMapSingle(workItem2 -> {
returnSingle.just(workItem2).subscribeOn(Schedulers.computation()).map(workItem -> {
try {
Thread.sleep(1000);
if (workItem == 2) {
thrownewException("Something in second block failed");
}
Thread.sleep(1000);
} catch (InterruptedExceptione) {
System.out.println("InterruptedException in block 2");
throwe;
}
returnworkItem;
});
}).blockingSubscribe(item -> System.out.println("Item finished " + item), err -> {
System.out.println("MyError: " + err.toString());
err.printStackTrace();
});
}
}
has 2 processing stages. If the first one throws an exception, the second one gets interrupted and throws an UndeliverableException. In the opposite case, if the 2nd block throws an exception, the 1st one gets interrupted, but its InterruptedException is completely ignored - not delivered to any error handler, nor thrown as UndeliverableException.
This is caused by some kind of race condition within ConcatMapSingleMainObserver. When the 2nd block throws, on the ConcatMapSingleMainObserver instance belonging to the 1st block, dispose is called before innerError. Because at this point errors is empty, addThrowable succeeds, but the drain loop is never called, because dispose has set the AtomicInteger to 1. Therefore, the exception in error is never retrieved and forwarded.
This can be fixed (if it needs fixing, anyways) by having innerError, dispose and the drain loop check for cancelled and forward exceptions to RxJavaPlugins.onError if appropriate. I will make a PR...
The text was updated successfully, but these errors were encountered:
…tMapCompletable, FlowableConcatMapMaybe, FlowableConcatMapSingle, ObservableConcatMap - forward errors to RxJavaPlugins.onError instead of swallowing them
Not sure if this intentional or a bug. The following code:
has 2 processing stages. If the first one throws an exception, the second one gets interrupted and throws an
UndeliverableException
. In the opposite case, if the 2nd block throws an exception, the 1st one gets interrupted, but itsInterruptedException
is completely ignored - not delivered to any error handler, nor thrown asUndeliverableException
.This is caused by some kind of race condition within
ConcatMapSingleMainObserver
. When the 2nd block throws, on theConcatMapSingleMainObserver
instance belonging to the 1st block,dispose
is called beforeinnerError
. Because at this pointerrors
is empty,addThrowable
succeeds, but thedrain
loop is never called, becausedispose
has set theAtomicInteger
to1
. Therefore, the exception inerror
is never retrieved and forwarded.This can be fixed (if it needs fixing, anyways) by having
innerError
,dispose
and thedrain
loop check forcancelled
and forward exceptions toRxJavaPlugins.onError
if appropriate. I will make a PR...The text was updated successfully, but these errors were encountered: