Skip to content

Commit ebab903

Browse files
artem-zinnatullinakarnokd
authored andcommitted
2.x: Add note about NoSuchElementException to Single.zip(). (#5876)
* 2.x: Add note about NoSuchElementException to Single.zip(). * Address code review comments.
1 parent d3ed269 commit ebab903

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/io/reactivex/Single.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ public static <T> Single<T> wrap(SingleSource<T> source) {
12791279
* value and calls a zipper function with an array of these values to return a result
12801280
* to be emitted to downstream.
12811281
* <p>
1282+
* If the {@code Iterable} of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled after subscription.
1283+
* <p>
12821284
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the
12831285
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a
12841286
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
@@ -1294,7 +1296,8 @@ public static <T> Single<T> wrap(SingleSource<T> source) {
12941296
* </dl>
12951297
* @param <T> the common value type
12961298
* @param <R> the result value type
1297-
* @param sources the Iterable sequence of SingleSource instances
1299+
* @param sources the Iterable sequence of SingleSource instances. An empty sequence will result in an
1300+
* {@code onError} signal of {@link NoSuchElementException}.
12981301
* @param zipper the function that receives an array with values from each SingleSource
12991302
* and should return a value to be emitted to downstream
13001303
* @return the new Single instance
@@ -1721,6 +1724,8 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Single<R> zip(
17211724
* value and calls a zipper function with an array of these values to return a result
17221725
* to be emitted to downstream.
17231726
* <p>
1727+
* If the array of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled immediately.
1728+
* <p>
17241729
* Note on method signature: since Java doesn't allow creating a generic array with {@code new T[]}, the
17251730
* implementation of this operator has to create an {@code Object[]} instead. Unfortunately, a
17261731
* {@code Function<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
@@ -1736,7 +1741,8 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Single<R> zip(
17361741
* </dl>
17371742
* @param <T> the common value type
17381743
* @param <R> the result value type
1739-
* @param sources the array of SingleSource instances
1744+
* @param sources the array of SingleSource instances. An empty sequence will result in an
1745+
* {@code onError} signal of {@link NoSuchElementException}.
17401746
* @param zipper the function that receives an array with values from each SingleSource
17411747
* and should return a value to be emitted to downstream
17421748
* @return the new Single instance

0 commit comments

Comments
 (0)