File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -68,8 +68,8 @@ public void onError(Throwable e) {
68
68
69
69
@ Override
70
70
public void onNext (T i ) {
71
- if (!isUnsubscribed ()) {
72
- boolean stop = ++ count > = limit ;
71
+ if (!isUnsubscribed () && count ++ < limit ) {
72
+ boolean stop = count = = limit ;
73
73
child .onNext (i );
74
74
if (stop && !completed ) {
75
75
completed = true ;
Original file line number Diff line number Diff line change 32
32
import rx .functions .*;
33
33
import rx .observers .*;
34
34
import rx .schedulers .Schedulers ;
35
+ import rx .subjects .PublishSubject ;
35
36
36
37
public class OperatorTakeTest {
37
38
@@ -417,4 +418,24 @@ public void onNext(Integer t) {
417
418
ts .assertError (TestException .class );
418
419
ts .assertNotCompleted ();
419
420
}
421
+
422
+ @ Test
423
+ public void testReentrantTake () {
424
+ final PublishSubject <Integer > source = PublishSubject .create ();
425
+
426
+ TestSubscriber <Integer > ts = new TestSubscriber <Integer >();
427
+
428
+ source .take (1 ).doOnNext (new Action1 <Integer >() {
429
+ @ Override
430
+ public void call (Integer v ) {
431
+ source .onNext (2 );
432
+ }
433
+ }).subscribe (ts );
434
+
435
+ source .onNext (1 );
436
+
437
+ ts .assertValue (1 );
438
+ ts .assertNoErrors ();
439
+ ts .assertCompleted ();
440
+ }
420
441
}
You can’t perform that action at this time.
0 commit comments