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 Flowable.singleOrError().toFlowable() not signalling NoSuchElementException #5904

Merged
merged 1 commit into from
Mar 9, 2018

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Mar 8, 2018

When a singleOrError is followed by toFlowable(), the assembly process switches the Flowable->Single operator into a Flowable->Flowable operator implementing the singleOrError behavior (saving the back-and-forth type conversion). The backing implementation was shared with singleElement and as such, did not properly handle the orError case for an empty source. The PR fixes the lack of NoSuchElementException in this case.

Fixes #5903.

The Observable variant doesn't have such optimization but the test has been converted to make sure Observable is verified for this aspect in case the optimization is implemented with it in the future.

@codecov
Copy link

codecov bot commented Mar 8, 2018

Codecov Report

Merging #5904 into 2.x will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5904      +/-   ##
============================================
+ Coverage     97.92%   97.97%   +0.04%     
- Complexity     5987     5989       +2     
============================================
  Files           655      655              
  Lines         43925    43929       +4     
  Branches       6087     6088       +1     
============================================
+ Hits          43014    43039      +25     
+ Misses          281      271      -10     
+ Partials        630      619      -11
Impacted Files Coverage Δ Complexity Δ
...ernal/operators/flowable/FlowableSingleSingle.java 97.95% <100%> (ø) 3 <1> (ø) ⬇️
...ex/internal/operators/flowable/FlowableSingle.java 100% <100%> (ø) 2 <1> (ø) ⬇️
...ternal/operators/flowable/FlowableSingleMaybe.java 100% <100%> (ø) 3 <1> (ø) ⬇️
...nternal/operators/parallel/ParallelReduceFull.java 91.08% <0%> (-3.97%) 2% <0%> (ø)
...nternal/operators/observable/ObservableCreate.java 95.65% <0%> (-2.61%) 2% <0%> (ø)
.../io/reactivex/disposables/CompositeDisposable.java 98.14% <0%> (-1.86%) 39% <0%> (-1%)
...internal/operators/observable/ObservableCache.java 93.7% <0%> (-1.58%) 9% <0%> (ø)
...ternal/operators/observable/ObservableFlatMap.java 86.58% <0%> (-1.28%) 3% <0%> (ø)
.../operators/mixed/FlowableSwitchMapCompletable.java 98.94% <0%> (-1.06%) 2% <0%> (ø)
.../operators/maybe/MaybeFlatMapIterableFlowable.java 97.54% <0%> (-0.82%) 2% <0%> (ø)
... and 24 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 5e5d5a2...9f1d846. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flowable.singleOrError() does not signal an exception if followed by flatMapPublisher
3 participants