Skip to content

Commit f20f479

Browse files
flatMapAsync test was non-deterministic
1 parent b86e1da commit f20f479

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

rxjava-core/src/test/java/rx/BackpressureTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ public Observable<Integer> call(Integer i) {
173173
}).take(NUM).subscribe(ts);
174174
ts.awaitTerminalEvent();
175175
ts.assertNoErrors();
176-
System.out.println("testFlatMapAsync => Received: " + ts.getOnNextEvents().size() + " Emitted: " + c.get());
176+
System.out.println("testFlatMapAsync => Received: " + ts.getOnNextEvents().size() + " Emitted: " + c.get() + " Size: " + RxRingBuffer.SIZE);
177177
assertEquals(NUM, ts.getOnNextEvents().size());
178-
// expect less than 1 buffer since the flatMap is emitting 10 each time, so it is NUM/10 that will be taken.
179-
assertTrue(c.get() <= RxRingBuffer.SIZE);
178+
// even though we only need 10, it will request at least RxRingBuffer.SIZE, and then as it drains keep requesting more
179+
// and then it will be non-deterministic when the take() causes the unsubscribe as it is scheduled on 10 different schedulers (threads)
180+
// normally this number is ~250 but can get up to ~1200 when RxRingBuffer.SIZE == 1024
181+
assertTrue(c.get() <= RxRingBuffer.SIZE * 2);
180182
}
181183

182184
@Ignore

0 commit comments

Comments
 (0)