Skip to content

Commit 16e55c3

Browse files
committed
Merge pull request #3536 from akarnokd/SyncOnSubscribeTestFix
1.x: Fix SyncOnSubscribeTest.testConcurrentRequests non-determinism
2 parents 9fddbd9 + f238c89 commit 16e55c3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/test/java/rx/observables/SyncOnSubscribeTest.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,14 @@ public void testConcurrentRequests() throws InterruptedException {
476476
final CountDownLatch l1 = new CountDownLatch(1);
477477
final CountDownLatch l2 = new CountDownLatch(1);
478478

479-
@SuppressWarnings("unchecked")
480-
Action1<? super Integer> onUnSubscribe = mock(Action1.class);
479+
final CountDownLatch l3 = new CountDownLatch(1);
480+
481+
final Action1<Object> onUnSubscribe = new Action1<Object>() {
482+
@Override
483+
public void call(Object t) {
484+
l3.countDown();
485+
}
486+
};
481487

482488
OnSubscribe<Integer> os = SyncOnSubscribe.createStateful(
483489
new Func0<Integer>() {
@@ -532,7 +538,10 @@ public Integer call(Integer state, Observer<? super Integer> observer) {
532538
inOrder.verify(o, times(finalCount)).onNext(any());
533539
inOrder.verify(o, times(1)).onCompleted();
534540
inOrder.verifyNoMoreInteractions();
535-
verify(onUnSubscribe, times(1)).call(any(Integer.class));
541+
542+
if (!l3.await(2, TimeUnit.SECONDS)) {
543+
fail("SyncOnSubscribe failed to countDown onUnSubscribe latch");
544+
}
536545
}
537546

538547
@Test

0 commit comments

Comments
 (0)