Skip to content

Conversation

@akarnokd
Copy link
Member

@akarnokd akarnokd commented Feb 5, 2016

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. range ignores negative requests but other sources may throw IAE in that case.

With the fix, the operator will throw IAE in assembly time.

@akarnokd akarnokd added the Bug label Feb 5, 2016
@zsxwing
Copy link
Member

zsxwing commented Feb 5, 2016

👍

@JakeWharton
Copy link
Contributor

Why not IAE on negative values for the operator? This seems like it could hide errors in math-based take values.

@akarnokd
Copy link
Member Author

akarnokd commented Feb 5, 2016

I don't know, could be some historical reasons from the early days of RxJava.

@zsxwing
Copy link
Member

zsxwing commented Feb 5, 2016

Could you also check skip?

@akarnokd
Copy link
Member Author

akarnokd commented Feb 5, 2016

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.

@zsxwing
Copy link
Member

zsxwing commented Feb 5, 2016

cc @ReactiveX/rxjava-committers thoughts about this?

@stealthcode
Copy link

For invalid inputs we've typically blown up as early as possible.

@artem-zinnatullin
Copy link
Contributor

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.

@stevegury
Copy link
Member

I vote for throwing IAE.
I don't consider it's an API change, more a bug fix.

@akarnokd
Copy link
Member Author

akarnokd commented Feb 6, 2016

Changed the fix to throw.

@vanniktech
Copy link
Collaborator

Any reason for not using ExpectedException, that way the exception message can also be verified plus it can be nailed down where the Exception is thrown (the moment you call take(-1)).

@akarnokd
Copy link
Member Author

akarnokd commented Feb 6, 2016

Because it is irrelevant in this case, what matters is the type IAE.

@stevegury
Copy link
Member

👍

akarnokd added a commit that referenced this pull request Feb 6, 2016
1.x: fix take(-1) not completing
@akarnokd akarnokd merged commit 21db16b into ReactiveX:1.x Feb 6, 2016
@akarnokd akarnokd deleted the TakeMinusNFix1x branch February 6, 2016 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants