Skip to content
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

2.x: Add note about NoSuchElementException to Single.zip(). #5876

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/main/java/io/reactivex/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,8 @@ public static <T> Single<T> wrap(SingleSource<T> source) {
* value and calls a zipper function with an array of these values to return a result
* to be emitted to downstream.
* <p>
* If the {@code Iterable} of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled after subscription.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add explanation if you think it adds value, something like:

/**
 * Since {@link Single} can't complete without value, there is nothing zip operator
 * can do about zipping 0 {@code Single}s.
 */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't sound good to me. Simply state the fact that empty sequence results in a NoSuchElementException.

* <p>
* 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<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
Expand All @@ -1294,7 +1296,7 @@ public static <T> Single<T> wrap(SingleSource<T> source) {
* </dl>
* @param <T> the common value type
* @param <R> the result value type
* @param sources the Iterable sequence of SingleSource instances
* @param sources the Iterable sequence of SingleSource instances, must not be empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An empty sequence will result in an onError signal of 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
Expand Down Expand Up @@ -1721,6 +1723,8 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Single<R> zip(
* value and calls a zipper function with an array of these values to return a result
* to be emitted to downstream.
* <p>
* If the array of {@link SingleSource}s is empty a {@link NoSuchElementException} error is signalled immediately.
* <p>
* 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<Integer[], R>} passed to the method would trigger a {@code ClassCastException}.
Expand All @@ -1736,7 +1740,7 @@ public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Single<R> zip(
* </dl>
* @param <T> the common value type
* @param <R> the result value type
* @param sources the array of SingleSource instances
* @param sources the array of SingleSource instances, must not be empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"An empty array will result in an onError signal of 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
Expand Down