Skip to content

Commit 2f7145a

Browse files
committed
ensure OperatorZipTest.testZipRace does not fail on slower machines
1 parent 3a7dca9 commit 2f7145a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/test/java/rx/internal/operators/OperatorZipTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,8 +1270,14 @@ public void onNext(Integer t) {
12701270
}
12711271
@Test(timeout = 10000)
12721272
public void testZipRace() {
1273+
long startTime = System.currentTimeMillis();
12731274
Observable<Integer> src = Observable.just(1).subscribeOn(Schedulers.computation());
1274-
for (int i = 0; i < 100000; i++) {
1275+
1276+
// now try and generate a hang by zipping src with itself repeatedly. A
1277+
// time limit of 9 seconds ( 1 second less than the test timeout) is
1278+
// used so that this test will not timeout on slow machines.
1279+
int i = 0;
1280+
while (System.currentTimeMillis()-startTime < 9000 && i++ < 100000) {
12751281
int value = Observable.zip(src, src, new Func2<Integer, Integer, Integer>() {
12761282
@Override
12771283
public Integer call(Integer t1, Integer t2) {

0 commit comments

Comments
 (0)