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: fix concatMapEager should accept 0 for prefetch #5189

Merged
merged 2 commits into from
Mar 15, 2017

Conversation

nmorioka
Copy link
Contributor

Fixes a bug that Flowable.concatMapEager(mapper , maxConcurrency , prefetch) and Observable.concatMapEager(mapper , maxConcurrency , prefetch) operators will not accept 0 and negative numbers.

Reported in #5185.

@akarnokd
Copy link
Member

I believe a 0 breaks the internals of the operator and -1 has the completely opposite effect, taking more memory.

Copy link
Member

@akarnokd akarnokd left a comment

Choose a reason for hiding this comment

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

The verifyPositive should be restored.
Optionally, you could add the ", positive" to the javadoc changes.

@@ -6780,7 +6780,6 @@ public final void blockingSubscribe(Subscriber<? super T> subscriber) {
public final <R> Flowable<R> concatMapEager(Function<? super T, ? extends Publisher<? extends R>> mapper,
int maxConcurrency, int prefetch) {
ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency");
ObjectHelper.verifyPositive(prefetch, "prefetch");
Copy link
Member

Choose a reason for hiding this comment

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

No, the validations were right, you shouldn't call with non-positive value.

@@ -5975,7 +5975,6 @@ public final void blockingSubscribe(Observer<? super T> subscriber) {
int maxConcurrency, int prefetch) {
ObjectHelper.requireNonNull(mapper, "mapper is null");
ObjectHelper.verifyPositive(maxConcurrency, "maxConcurrency");
ObjectHelper.verifyPositive(prefetch, "prefetch");
Copy link
Member

Choose a reason for hiding this comment

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

No, the validations were right, you shouldn't call with non-positive value.

@@ -6770,7 +6770,7 @@ public final void blockingSubscribe(Subscriber<? super T> subscriber) {
* @param mapper the function that maps a sequence of values into a sequence of Publishers that will be
* eagerly concatenated
* @param maxConcurrency the maximum number of concurrent subscribed Publishers
* @param prefetch hints about the number of expected source sequence values
* @param prefetch hints about the number of expected values from each inner Publisher
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be reinforced:

hints about the number of expected values from each inner Publisher, must be positive

@nmorioka
Copy link
Contributor Author

I am sorry with the wrong fix.
Is it only necessary to modify the document?

@akarnokd
Copy link
Member

Is it only necessary to modify the document?

Yes. Please modify only the javadoc.

@nmorioka
Copy link
Contributor Author

Thank you!

Also, I think that the test case name is wrong, so I modifed it.

@codecov
Copy link

codecov bot commented Mar 15, 2017

Codecov Report

Merging #5189 into 2.x will decrease coverage by 0.05%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##                2.x    #5189      +/-   ##
============================================
- Coverage     96.02%   95.97%   -0.06%     
  Complexity     5670     5670              
============================================
  Files           621      621              
  Lines         40581    40581              
  Branches       5620     5620              
============================================
- Hits          38969    38946      -23     
- Misses          640      661      +21     
- Partials        972      974       +2
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/reactivex/Observable.java 100% <ø> (ø) 506 <0> (ø)
src/main/java/io/reactivex/Flowable.java 100% <ø> (ø) 522 <0> (ø)
...al/operators/observable/ObservableSampleTimed.java 88.33% <0%> (-10%) 3% <0%> (ø)
...vex/internal/operators/single/SingleTakeUntil.java 86.88% <0%> (-8.2%) 2% <0%> (ø)
.../operators/completable/CompletableConcatArray.java 93.75% <0%> (-6.25%) 2% <0%> (ø)
...rnal/subscribers/SinglePostCompleteSubscriber.java 94.87% <0%> (-5.13%) 14% <0%> (-1%)
...in/java/io/reactivex/subjects/BehaviorSubject.java 84.97% <0%> (-4.67%) 56% <0%> (+1%)
...a/io/reactivex/internal/util/QueueDrainHelper.java 60.28% <0%> (-4.26%) 32% <0%> (-3%)
...erators/completable/CompletableConcatIterable.java 95.91% <0%> (-4.09%) 2% <0%> (ø)
...vex/internal/operators/parallel/ParallelRunOn.java 94.41% <0%> (-3.05%) 6% <0%> (ø)
... and 35 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b58642b...69e3b23. Read the comment docs.

@akarnokd
Copy link
Member

Thanks for the contribution!

@akarnokd akarnokd merged commit ce1f2d0 into ReactiveX:2.x Mar 15, 2017
@nmorioka nmorioka deleted the ConcatMapEagerUseDefault branch March 16, 2017 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants