From 9f9617cf4a909624e93c515713aba3d80ce94658 Mon Sep 17 00:00:00 2001 From: Artem Zinnatullin Date: Fri, 2 Mar 2018 08:49:46 -0800 Subject: [PATCH 1/2] 2.x: Add note about NoSuchElementException to Single.zip(). --- src/main/java/io/reactivex/Single.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/reactivex/Single.java b/src/main/java/io/reactivex/Single.java index 8f4ab31fd4..72b1e8077e 100644 --- a/src/main/java/io/reactivex/Single.java +++ b/src/main/java/io/reactivex/Single.java @@ -1279,6 +1279,8 @@ public static Single wrap(SingleSource source) { * value and calls a zipper function with an array of these values to return a result * to be emitted to downstream. *

+ * If the {@code Iterable} of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled after subscription. + *

* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the * implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a * {@code Function} passed to the method would trigger a {@code ClassCastException}. @@ -1294,7 +1296,7 @@ public static Single wrap(SingleSource source) { * * @param the common value type * @param the result value type - * @param sources the Iterable sequence of SingleSource instances + * @param sources the Iterable sequence of SingleSource instances, must not be empty * @param zipper the function that receives an array with values from each SingleSource * and should return a value to be emitted to downstream * @return the new Single instance @@ -1721,6 +1723,8 @@ public static Single zip( * value and calls a zipper function with an array of these values to return a result * to be emitted to downstream. *

+ * If the array of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled immediately. + *

* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the * implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a * {@code Function} passed to the method would trigger a {@code ClassCastException}. @@ -1736,7 +1740,7 @@ public static Single zip( * * @param the common value type * @param the result value type - * @param sources the array of SingleSource instances + * @param sources the array of SingleSource instances, must not be empty * @param zipper the function that receives an array with values from each SingleSource * and should return a value to be emitted to downstream * @return the new Single instance From d503378d5318bcc319f766d0ffa2baa040877ddd Mon Sep 17 00:00:00 2001 From: Artem Zinnatullin Date: Fri, 2 Mar 2018 09:02:11 -0800 Subject: [PATCH 2/2] Address code review comments. --- src/main/java/io/reactivex/Single.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/reactivex/Single.java b/src/main/java/io/reactivex/Single.java index 72b1e8077e..2ef5a5d63e 100644 --- a/src/main/java/io/reactivex/Single.java +++ b/src/main/java/io/reactivex/Single.java @@ -1296,7 +1296,8 @@ public static Single wrap(SingleSource source) { * * @param the common value type * @param the result value type - * @param sources the Iterable sequence of SingleSource instances, must not be empty + * @param sources the Iterable sequence of SingleSource instances. An empty sequence will result in an + * {@code onError} signal of {@link NoSuchElementException}. * @param zipper the function that receives an array with values from each SingleSource * and should return a value to be emitted to downstream * @return the new Single instance @@ -1740,7 +1741,8 @@ public static Single zip( * * @param the common value type * @param the result value type - * @param sources the array of SingleSource instances, must not be empty + * @param sources the array of SingleSource instances. An empty sequence will result in an + * {@code onError} signal of {@link NoSuchElementException}. * @param zipper the function that receives an array with values from each SingleSource * and should return a value to be emitted to downstream * @return the new Single instance