Skip to content

Commit

Permalink
Ignore furthur messages after entering terminate state
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxwing committed Sep 2, 2014
1 parent f10fe76 commit ca011ff
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,22 @@ public OperatorOnErrorReturn(Func1<Throwable, ? extends T> resultFunction) {
public Subscriber<? super T> call(final Subscriber<? super T> child) {
return new Subscriber<T>(child) {

private boolean done = false;

@Override
public void onNext(T t) {
if (done) {
return;
}
child.onNext(t);
}

@Override
public void onError(Throwable e) {
if (done) {
return;
}
done = true;
try {
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
T result = resultFunction.call(e);
Expand All @@ -73,6 +82,10 @@ public void onError(Throwable e) {

@Override
public void onCompleted() {
if (done) {
return;
}
done = true;
child.onCompleted();
}

Expand Down

0 comments on commit ca011ff

Please sign in to comment.