-
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
Zip calls onNext later than C#'s Zip does #387
Comments
This unit test demonstrates the issue: @Test
public void testOnFirstCompletion() {
PublishSubject<String> oA = PublishSubject.create();
PublishSubject<String> oB = PublishSubject.create();
@SuppressWarnings("unchecked")
Observer<String> observer = mock(Observer.class);
Observable<String> o = Observable.create(zip(oA, oB, getConcat2Strings()));
o.subscribe(observer);
InOrder inOrder = inOrder(observer);
oA.onNext("a1");
inOrder.verify(observer, never()).onNext(anyString());
oB.onNext("b1");
inOrder.verify(observer, times(1)).onNext("a1-b1");
oB.onNext("b2");
inOrder.verify(observer, never()).onNext(anyString());
oA.onNext("a2");
inOrder.verify(observer, times(1)).onNext("a2-b2");
oA.onNext("a3");
oA.onNext("a4");
oA.onNext("a5");
oA.onCompleted();
// assert we complete the zip stream here
inOrder.verify(observer, times(1)).onCompleted();
oB.onNext("b3");
oB.onNext("b4");
oB.onNext("b5");
oB.onNext("b6");
oB.onNext("b7");
// never completes (infinite stream for example)
// we should receive nothing else despite oB continuing after oA completed
inOrder.verifyNoMoreInteractions();
} |
I need to play more with the C# version before I finish the changes, as fixing this unit test could be done in different ways, and the most obvious one breaks other unit tests. |
Branch with unit test at benjchristensen@6921f72 |
Hello, I've ported my Zip implementation and it appears to be doing almost the expected behavior: akarnokd@cd0a5e7 0 at t=1016 The difference to Rx seems to be that it terminates right after the 3rd item whereas Rx.NET after rejecting the 4th item of the second observable. |
Added tests while validating pull request. This fixes issue ReactiveX#387
Added tests while validating pull request. This fixes issue ReactiveX#387
In the C# example below, the zipped Observable completes as soon as o3 has completed, because all of o3's elements have been paired with an element from o6.
outputs
In the corresponding Java code, however, the zipped Observable only completes once both o3 and o6 have completed.
outputs
I'd like RxJava to follow C# here, unless there are very good reasons against doing so.
This difference becomes even more important if one of the observables never completes: Then, the zipped Observable never completes either, which was very unexpected for me.
The text was updated successfully, but these errors were encountered: