Skip to content

Window with skip > size doesn't request enough #3176

Closed
@akarnokd

Description

@akarnokd

The following test fails because Window forgets to request the 'gaps' between elements if skip > size:

@Test
public void testBackpressureWithLargeSkip() {
    TestSubscriber<Observable<Integer>> ts = new TestSubscriber<Observable<Integer>>(2) {
        @Override
        public void onNext(Observable<Integer> t) {
            AsyncSubject<Integer> as = AsyncSubject.create();
            t.subscribe(as);
            super.onNext(as);
        }
    };

    Observable.just(1, 2, 3)
    .window(1, 2)
    .subscribe(ts);

    ts.assertCompleted();
    ts.assertNoErrors();
    ts.assertValueCount(2);
}

Note that due to potential conflict with #3150, I won't create a PR to fix this right now but will post a PR that adds some helper methods to BackpressureUtils to deal with add/multiply overflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions