-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for overlapping windows. #2897
Conversation
Could you add the unit test from your gist as well? |
Ah, someone else's gist. Still, as the unit test is there may as well chuck it in. |
Thanks for the feedback. Is it kosher to do a sleep in the test? Its the Also, it doesn't seem too reliable to depend upon sleep. |
Good catch! An unit test would be great, but you don't really need concurrency: reentrancy will do just fine: @Test
public void testWindowNoDuplication() {
final PublishSubject<Integer> source = PublishSubject.create();
final TestSubscriber<Integer> tsw = new TestSubscriber<Integer>() {
boolean once;
@Override
public void onNext(Integer t) {
if (!once) {
once = true;
source.onNext(2);
}
super.onNext(t);
}
};
TestSubscriber<Observable<Integer>> ts = new TestSubscriber<Observable<Integer>>() {
@Override
public void onNext(Observable<Integer> t) {
t.subscribe(tsw);
super.onNext(t);
}
};
source.window(new Func0<Observable<Object>>() {
@Override
public Observable<Object> call() {
return Observable.never();
}
}).subscribe(ts);
source.onNext(1);
source.onCompleted();
assertEquals(1, ts.getOnNextEvents().size());
assertEquals(Arrays.asList(1, 2), tsw.getOnNextEvents());
} |
…tiple times while holding queue.
Thanks @akarnokd - great test! |
Thanks! |
Should I push a patch release with this today? |
A verification on #2878 would be great. After that, the patch release can commence. |
Source was emitting t multiple times while holding queue.
Fixes #2896