-
Notifications
You must be signed in to change notification settings - Fork 7.6k
1.x: fix take(-1) not completing #3675
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
Conversation
|
👍 |
|
Why not IAE on negative values for the operator? This seems like it could hide errors in math-based |
|
I don't know, could be some historical reasons from the early days of RxJava. |
|
Just checked Rx.Net and RxJS. Both them throw an error for negative values: https://github.com/Reactive-Extensions/Rx.NET/blob/859e6159cb07be67fd36b18c2ae2b9a62979cb6d/Rx.NET/Source/System.Reactive.Linq/Reactive/Linq/Observable.StandardSequenceOperators.cs#L1279 So I suggest let's throw IAE. |
|
Could you also check |
|
skip(0) and skip(-1) just returns the source without applying the operator to it. For 2.x, definitely, but I'm not certain about 1.x, sounds like an API change. |
|
cc @ReactiveX/rxjava-committers thoughts about this? |
|
For invalid inputs we've typically blown up as early as possible. |
|
I think we need to throw exception. We can highlight this in changelog and call it a bug fix because it actually is, I guess. |
|
I vote for throwing IAE. |
a761cd9 to
e8059c6
Compare
|
Changed the fix to throw. |
|
Any reason for not using |
|
Because it is irrelevant in this case, what matters is the type IAE. |
|
👍 |
1.x: fix take(-1) not completing
Originally, only 0 was checked which resulted in
onCompleted()but negative values weren't. When the downstream requested, c became -1 and was requested from the source.rangeignores negative requests but other sources may throw IAE in that case.With the fix, the operator will throw IAE in assembly time.