Skip to content

Commit 76517d9

Browse files
authored
1.x: fix Completable.onErrorComplete(Func1) not relaying function crash (#4027)
1 parent 8e127a5 commit 76517d9

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/rx/Completable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,8 +1663,9 @@ public void onError(Throwable e) {
16631663
try {
16641664
b = predicate.call(e);
16651665
} catch (Throwable ex) {
1666+
Exceptions.throwIfFatal(ex);
16661667
e = new CompositeException(Arrays.asList(e, ex));
1667-
return;
1668+
b = false;
16681669
}
16691670

16701671
if (b) {

src/test/java/rx/CompletableTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4112,4 +4112,29 @@ public void onStart() {
41124112
ts.assertCompleted();
41134113
}
41144114

4115+
@Test
4116+
public void onErrorCompleteFunctionThrows() {
4117+
TestSubscriber<String> ts = new TestSubscriber<String>();
4118+
4119+
error.completable.onErrorComplete(new Func1<Throwable, Boolean>() {
4120+
@Override
4121+
public Boolean call(Throwable t) {
4122+
throw new TestException("Forced inner failure");
4123+
}
4124+
}).subscribe(ts);
4125+
4126+
ts.assertNoValues();
4127+
ts.assertNotCompleted();
4128+
ts.assertError(CompositeException.class);
4129+
4130+
CompositeException composite = (CompositeException)ts.getOnErrorEvents().get(0);
4131+
4132+
List<Throwable> errors = composite.getExceptions();
4133+
Assert.assertEquals(2, errors.size());
4134+
4135+
Assert.assertTrue(errors.get(0).toString(), errors.get(0) instanceof TestException);
4136+
Assert.assertEquals(errors.get(0).toString(), null, errors.get(0).getMessage());
4137+
Assert.assertTrue(errors.get(1).toString(), errors.get(1) instanceof TestException);
4138+
Assert.assertEquals(errors.get(1).toString(), "Forced inner failure", errors.get(1).getMessage());
4139+
}
41154140
}

0 commit comments

Comments
 (0)