-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
2.x: Add note about NoSuchElementException to Single.zip(). #5876
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no such requirement that these should be not empty, only consequence of being empty.
@@ -1294,7 +1296,7 @@ | |||
* </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 |
There was a problem hiding this comment.
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
."
@@ -1736,7 +1740,7 @@ | |||
* </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 |
There was a problem hiding this comment.
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
."
@@ -1279,6 +1279,8 @@ | |||
* 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. |
There was a problem hiding this comment.
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.
*/
There was a problem hiding this comment.
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.
This may be a desirable documentation enhancement the other |
Yep, I'll check other rx types to update that, for some types like Will post comment with update in any case :) |
Codecov Report
@@ Coverage Diff @@
## 2.x #5876 +/- ##
============================================
+ Coverage 96.59% 96.64% +0.04%
- Complexity 5893 5894 +1
============================================
Files 652 652
Lines 43403 43403
Branches 6033 6033
============================================
+ Hits 41926 41946 +20
+ Misses 567 555 -12
+ Partials 910 902 -8
Continue to review full report at Codecov.
|
An empty input sequence to zip sounds more like a mistake to be warned about instead of a feature. |
So I briefly checked
And they emit completion if input is an empty collection of sources. I agree that if you care about emitted value, "silent" completion is not great. For consistency with other rx types I'd still suggest to return An alternative would be to emit error from other rx types in this scenario, but such change doesn't sound pragmatic Note:
|
No description provided.