Skip to content

Commit a761cd9

Browse files
committed
1.x: fix take(-1) not completing
1 parent 5530fc4 commit a761cd9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/java/rx/internal/operators/OperatorTake.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ else if (requested.compareAndSet(r, r + c)) {
114114

115115
};
116116

117-
if (limit == 0) {
117+
if (limit <= 0) {
118118
child.onCompleted();
119119
parent.unsubscribe();
120120
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,16 @@ public void call(Integer v) {
438438
ts.assertNoErrors();
439439
ts.assertCompleted();
440440
}
441+
442+
@Test(timeout = 1000)
443+
public void takeNegative() {
444+
TestSubscriber<Integer> ts = TestSubscriber.create();
445+
446+
Observable.range(1, 1000 * 1000 * 1000).take(-1).subscribe(ts);
447+
448+
ts.assertNoValues();
449+
ts.assertNoErrors();
450+
ts.assertCompleted();
451+
}
452+
441453
}

0 commit comments

Comments
 (0)