Skip to content

Commit c7f7d57

Browse files
Todd Ninebenjchristensen
authored andcommitted
Added additional test to prove issue
1 parent 27c0956 commit c7f7d57

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

rxjava-core/src/test/java/rx/ZipTests.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
*/
1616
package rx;
1717

18+
import static org.junit.Assert.*;
19+
20+
import java.util.Collection;
21+
import java.util.Collections;
1822
import java.util.HashMap;
1923
import java.util.Map;
2024

@@ -31,6 +35,7 @@
3135
import rx.functions.Action1;
3236
import rx.functions.Func1;
3337
import rx.functions.Func2;
38+
import rx.functions.FuncN;
3439
import rx.observables.GroupedObservable;
3540

3641
public class ZipTests {
@@ -91,6 +96,28 @@ public void testCovarianceOfZip() {
9196
Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine);
9297
}
9398

99+
/**
100+
* Occasionally zip may be invoked with 0 observables. This blocks indefinitely instead
101+
* of immediately invoking zip with 0 argument.
102+
*/
103+
@Test(timeout = 5000)
104+
public void nonBlockingObservable() {
105+
106+
final Object invoked = new Object();
107+
108+
Collection<Observable<Object>> observables = Collections.emptyList();
109+
110+
Observable<Object> result = Observable.zip(observables, new FuncN<Object>() {
111+
@Override
112+
public Object call(final Object... args) {
113+
assertEquals("No argument should have been passed", 0, args.length);
114+
return invoked;
115+
}
116+
});
117+
118+
assertSame(invoked, result.toBlockingObservable().last());
119+
}
120+
94121
Func2<Media, Rating, ExtendedResult> combine = new Func2<Media, Rating, ExtendedResult>() {
95122
@Override
96123
public ExtendedResult call(Media m, Rating r) {

0 commit comments

Comments
 (0)