Skip to content

Commit 191f023

Browse files
Pratakarnokd
Prat
authored andcommitted
1.x: Fix Completable swallows OnErrorNotImplementedException (#3904)
1 parent 2bf53a9 commit 191f023

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/java/rx/Completable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,7 @@ public final void subscribe(CompletableSubscriber s) {
19721972
throw ex;
19731973
} catch (Throwable ex) {
19741974
ERROR_HANDLER.handleError(ex);
1975+
Exceptions.throwIfFatal(ex);
19751976
throw toNpe(ex);
19761977
}
19771978
}

src/test/java/rx/CompletableTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2813,6 +2813,30 @@ public void call() {
28132813
});
28142814
}
28152815

2816+
@Test(expected = OnErrorNotImplementedException.class)
2817+
public void propagateExceptionSubscribeEmpty() {
2818+
error.completable.toSingleDefault(0).subscribe();
2819+
}
2820+
2821+
@Test(expected = OnErrorNotImplementedException.class)
2822+
public void propagateExceptionSubscribeOneAction() {
2823+
error.completable.toSingleDefault(1).subscribe(new Action1<Integer>() {
2824+
@Override
2825+
public void call(Integer integer) {
2826+
}
2827+
});
2828+
}
2829+
2830+
@Test(expected = OnErrorNotImplementedException.class)
2831+
public void propagateExceptionSubscribeOneActionThrowFromOnSuccess() {
2832+
normal.completable.toSingleDefault(1).subscribe(new Action1<Integer>() {
2833+
@Override
2834+
public void call(Integer integer) {
2835+
throw new TestException();
2836+
}
2837+
});
2838+
}
2839+
28162840
@Test(timeout = 1000)
28172841
public void timeoutEmitError() {
28182842
Throwable e = Completable.never().timeout(100, TimeUnit.MILLISECONDS).get();

0 commit comments

Comments
 (0)