Skip to content

Commit

Permalink
Merge pull request #1657 from zsxwing/fix-onErrorReturn
Browse files Browse the repository at this point in the history
Ignore furthur messages after entering terminate state
  • Loading branch information
benjchristensen committed Sep 5, 2014
2 parents 69fa2ff + ca011ff commit 4dc2e7a
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 4dc2e7a

Please sign in to comment.