Skip to content
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

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

Merged
merged 1 commit into from Sep 30, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -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}
@@ -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
@@ -1084,4 +1084,25 @@ public Object call(Object t) {
}
}

@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();
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.