Skip to content

Commit 63e2b58

Browse files
zsxwingbenjchristensen
authored andcommitted
Ignore furthur messages after entering terminate state
1 parent 7ba2636 commit 63e2b58

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/rx/internal/operators/OperatorOnErrorReturn.java

+13
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)