File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
main/java/rx/internal/operators
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -268,8 +268,12 @@ public void setProducer(Producer p) {
268
268
if (producer != null ) {
269
269
throw new IllegalStateException ("Can't set more than one Producer!" );
270
270
}
271
+ mr = missedRequested ;
271
272
// request one less because of the initial value, this happens once
272
- mr = missedRequested - 1 ;
273
+ // and is performed only if the request is not at MAX_VALUE already
274
+ if (mr != Long .MAX_VALUE ) {
275
+ mr -= 1 ;
276
+ }
273
277
missedRequested = 0L ;
274
278
producer = p ;
275
279
}
Original file line number Diff line number Diff line change @@ -451,4 +451,22 @@ public void onNext(Integer t) {
451
451
}
452
452
});
453
453
}
454
+
455
+ @ Test
456
+ public void scanShouldPassUpstreamARequestForMaxValue () {
457
+ final List <Long > requests = new ArrayList <Long >();
458
+ Observable .just (1 ,2 ,3 ).doOnRequest (new Action1 <Long >() {
459
+ @ Override
460
+ public void call (Long n ) {
461
+ requests .add (n );
462
+ }
463
+ })
464
+ .scan (new Func2 <Integer ,Integer , Integer >() {
465
+ @ Override
466
+ public Integer call (Integer t1 , Integer t2 ) {
467
+ return 0 ;
468
+ }}).count ().subscribe ();
469
+
470
+ assertEquals (Arrays .asList (Long .MAX_VALUE ), requests );
471
+ }
454
472
}
You can’t perform that action at this time.
0 commit comments