Skip to content

Commit 4388cee

Browse files
committed
handle multiple onError calls
1 parent 75fdc86 commit 4388cee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

rxjava-core/src/main/java/rx/operators/OperationOnErrorResumeNextViaObservable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ public void onNext(T value) {
8484
public void onError(Exception ex) {
8585
/* remember what the current subscription is so we can determine if someone unsubscribes concurrently */
8686
AtomicObservableSubscription currentSubscription = subscriptionRef.get();
87-
// check that we have not been unsubscribed before we can process the error
88-
if (currentSubscription != null) {
87+
// check that we have not been unsubscribed and not already resumed before we can process the error
88+
if (currentSubscription == subscription) {
8989
/* error occurred, so switch subscription to the 'resumeSequence' */
9090
AtomicObservableSubscription innerSubscription = new AtomicObservableSubscription(resumeSequence.subscribe(observer));
9191
/* we changed the sequence, so also change the subscription to the one of the 'resumeSequence' instead */
@@ -148,8 +148,8 @@ public void testResumeNext() {
148148
@Test
149149
public void testMapResumeAsyncNext() {
150150
Subscription sr = mock(Subscription.class);
151-
// Trigger failure on the second event
152-
Observable<String> w = Observable.from("one", "fail", "two", "three");
151+
// Trigger multiple failures
152+
Observable<String> w = Observable.from("one", "fail", "two", "three", "fail");
153153
// Resume Observable is async
154154
TestObservable resume = new TestObservable(sr, "twoResume", "threeResume");
155155

0 commit comments

Comments
 (0)