Skip to content

throwIfFatal() now throws OnCompletedFailedException #3886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/rx/exceptions/Exceptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static RuntimeException propagate(Throwable t) {
* <ul>
* <li>{@link OnErrorNotImplementedException}</li>
* <li>{@link OnErrorFailedException}</li>
* <li>{@link OnCompletedFailedException}</li>
* <li>{@code StackOverflowError}</li>
* <li>{@code VirtualMachineError}</li>
* <li>{@code ThreadDeath}</li>
Expand All @@ -80,6 +81,8 @@ public static void throwIfFatal(Throwable t) {
throw (OnErrorNotImplementedException) t;
} else if (t instanceof OnErrorFailedException) {
throw (OnErrorFailedException) t;
} else if (t instanceof OnCompletedFailedException) {
throw (OnCompletedFailedException) t;
}
// values here derived from https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495
else if (t instanceof StackOverflowError) {
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/rx/exceptions/ExceptionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ public void call(Integer t1) {
});
}

/**
* https://github.com/ReactiveX/RxJava/issues/3885
*/
@Test(expected = OnCompletedFailedException.class)
public void testOnCompletedExceptionIsThrown() {
Observable.empty()
.subscribe(new Subscriber<Object>() {
@Override
public void onCompleted() {
throw new RuntimeException();
}

@Override
public void onError(Throwable e) {
}

@Override
public void onNext(Object o) {
}
});
}

@Test
public void testStackOverflowWouldOccur() {
final PublishSubject<Integer> a = PublishSubject.create();
Expand Down