Skip to content

Commit 5c67fe4

Browse files
committed
Update unsubscribeOn tests to avoid the termination-cancel race
1 parent 592b991 commit 5c67fe4

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/test/java/io/reactivex/internal/operators/flowable/FlowableUnsubscribeOnTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public void subscribe(Subscriber<? super Integer> t1) {
4747
t1.onSubscribe(subscription);
4848
t1.onNext(1);
4949
t1.onNext(2);
50-
t1.onComplete();
50+
// observeOn will prevent canceling the upstream upon its termination now
51+
// this call is racing for that state in this test
52+
// not doing it will make sure the unsubscribeOn always gets through
53+
// t1.onComplete();
5154
}
5255
});
5356

@@ -93,7 +96,10 @@ public void subscribe(Subscriber<? super Integer> t1) {
9396
t1.onSubscribe(subscription);
9497
t1.onNext(1);
9598
t1.onNext(2);
96-
t1.onComplete();
99+
// observeOn will prevent canceling the upstream upon its termination now
100+
// this call is racing for that state in this test
101+
// not doing it will make sure the unsubscribeOn always gets through
102+
// t1.onComplete();
97103
}
98104
});
99105

src/test/java/io/reactivex/internal/operators/observable/ObservableUnsubscribeOnTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public void subscribe(Observer<? super Integer> t1) {
4646
t1.onSubscribe(subscription);
4747
t1.onNext(1);
4848
t1.onNext(2);
49-
t1.onComplete();
49+
// observeOn will prevent canceling the upstream upon its termination now
50+
// this call is racing for that state in this test
51+
// not doing it will make sure the unsubscribeOn always gets through
52+
// t1.onComplete();
5053
}
5154
});
5255

@@ -92,7 +95,10 @@ public void subscribe(Observer<? super Integer> t1) {
9295
t1.onSubscribe(subscription);
9396
t1.onNext(1);
9497
t1.onNext(2);
95-
t1.onComplete();
98+
// observeOn will prevent canceling the upstream upon its termination now
99+
// this call is racing for that state in this test
100+
// not doing it will make sure the unsubscribeOn always gets through
101+
// t1.onComplete();
96102
}
97103
});
98104

0 commit comments

Comments
 (0)