From c7f7d5787dcff1019ba9e411b1353a9be2f1faf2 Mon Sep 17 00:00:00 2001 From: Todd Nine Date: Wed, 12 Feb 2014 20:33:37 -0700 Subject: [PATCH] Added additional test to prove issue --- rxjava-core/src/test/java/rx/ZipTests.java | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rxjava-core/src/test/java/rx/ZipTests.java b/rxjava-core/src/test/java/rx/ZipTests.java index 97928a5092..262f7dcb74 100644 --- a/rxjava-core/src/test/java/rx/ZipTests.java +++ b/rxjava-core/src/test/java/rx/ZipTests.java @@ -15,6 +15,10 @@ */ package rx; +import static org.junit.Assert.*; + +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -31,6 +35,7 @@ import rx.functions.Action1; import rx.functions.Func1; import rx.functions.Func2; +import rx.functions.FuncN; import rx.observables.GroupedObservable; public class ZipTests { @@ -91,6 +96,28 @@ public void testCovarianceOfZip() { Observable. zip(horrors, ratings, combine); } + /** + * Occasionally zip may be invoked with 0 observables. This blocks indefinitely instead + * of immediately invoking zip with 0 argument. + */ + @Test(timeout = 5000) + public void nonBlockingObservable() { + + final Object invoked = new Object(); + + Collection> observables = Collections.emptyList(); + + Observable result = Observable.zip(observables, new FuncN() { + @Override + public Object call(final Object... args) { + assertEquals("No argument should have been passed", 0, args.length); + return invoked; + } + }); + + assertSame(invoked, result.toBlockingObservable().last()); + } + Func2 combine = new Func2() { @Override public ExtendedResult call(Media m, Rating r) {