Skip to content

Commit 4dc2e7a

Browse files
Merge pull request #1657 from zsxwing/fix-onErrorReturn
Ignore furthur messages after entering terminate state
2 parents 69fa2ff + ca011ff commit 4dc2e7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

rxjava-core/src/main/java/rx/internal/operators/OperatorOnErrorReturn.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ public OperatorOnErrorReturn(Func1<Throwable, ? extends T> resultFunction) {
5252
public Subscriber<? super T> call(final Subscriber<? super T> child) {
5353
return new Subscriber<T>(child) {
5454

55+
private boolean done = false;
56+
5557
@Override
5658
public void onNext(T t) {
59+
if (done) {
60+
return;
61+
}
5762
child.onNext(t);
5863
}
5964

6065
@Override
6166
public void onError(Throwable e) {
67+
if (done) {
68+
return;
69+
}
70+
done = true;
6271
try {
6372
RxJavaPlugins.getInstance().getErrorHandler().handleError(e);
6473
T result = resultFunction.call(e);
@@ -73,6 +82,10 @@ public void onError(Throwable e) {
7382

7483
@Override
7584
public void onCompleted() {
85+
if (done) {
86+
return;
87+
}
88+
done = true;
7689
child.onCompleted();
7790
}
7891

0 commit comments

Comments
 (0)