Skip to content

1.x: SafeSubscriber not to call RxJavaHooks before delivering the original error. #4641

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
Sep 30, 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
5 changes: 3 additions & 2 deletions src/main/java/rx/observers/SafeSubscriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import rx.Subscriber;
import rx.exceptions.*;
import rx.plugins.RxJavaHooks;
import rx.plugins.*;

/**
* {@code SafeSubscriber} is a wrapper around {@code Subscriber} that ensures that the {@code Subscriber}
Expand Down Expand Up @@ -146,8 +146,9 @@ public void onNext(T args) {
*
* @see <a href="https://github.com/ReactiveX/RxJava/issues/630">the report of this bug</a>
*/
@SuppressWarnings("deprecation")
protected void _onError(Throwable e) { // NOPMD
RxJavaHooks.onError(e);
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
try {
actual.onError(e);
} catch (OnErrorNotImplementedException e2) { // NOPMD
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/rx/plugins/RxJavaHooksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1084,4 +1084,25 @@ public Completable.Operator onLift(Completable.Operator lift) {
}
}

@Test
public void noCallToHooksOnPlainError() {

final boolean[] called = { false };

RxJavaHooks.setOnError(new Action1<Throwable>() {
@Override
public void call(Throwable t) {
called[0] = true;
}
});

try {
Observable.error(new TestException())
.subscribe(new TestSubscriber<Object>());

assertFalse(called[0]);
} finally {
RxJavaHooks.reset();
}
}
}