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: Check isdisposed before emitting in SingleFromCallable #5743

Merged
merged 1 commit into from
Nov 25, 2017

Conversation

runningcode
Copy link
Contributor

Previously SingleFromCallable did not check if the subscriber was
unsubscribed before emitting onSuccess or onError. This fixes that
behavior and adds tests to SingleFromCallable, CompletableFromCallable,
and MaybeFromCallable.

Fixes #5742

T v = callable.call();
if (v != null) {
s.onSuccess(v);
value = ObjectHelper.requireNonNull(callable.call(), "Callable returned null");
Copy link
Member

Choose a reason for hiding this comment

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

You got the error message wrong.

Travis CI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 fixed now :)

@codecov
Copy link

codecov bot commented Nov 25, 2017

Codecov Report

Merging #5743 into 2.x will decrease coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5743      +/-   ##
============================================
- Coverage     96.29%   96.22%   -0.07%     
- Complexity     5833     5836       +3     
============================================
  Files           634      634              
  Lines         41615    41620       +5     
  Branches       5761     5763       +2     
============================================
- Hits          40073    40050      -23     
- Misses          611      634      +23     
- Partials        931      936       +5
Impacted Files Coverage Δ Complexity Δ
.../internal/operators/single/SingleFromCallable.java 100% <100%> (ø) 5 <4> (+2) ⬆️
.../io/reactivex/internal/functions/ObjectHelper.java 94.73% <0%> (-5.27%) 20% <0%> (-1%)
.../operators/observable/ObservableFlatMapSingle.java 90.29% <0%> (-4.48%) 2% <0%> (ø)
...nternal/operators/observable/ObservableCreate.java 93.16% <0%> (-4.28%) 2% <0%> (ø)
...a/io/reactivex/internal/util/QueueDrainHelper.java 60.28% <0%> (-4.26%) 32% <0%> (-3%)
...ava/io/reactivex/processors/BehaviorProcessor.java 90.26% <0%> (-3.99%) 61% <0%> (ø)
...tivex/internal/observers/FutureSingleObserver.java 94.33% <0%> (-3.78%) 24% <0%> (-1%)
...l/operators/observable/ObservableFlatMapMaybe.java 87.58% <0%> (-2.62%) 2% <0%> (ø)
...tivex/internal/schedulers/TrampolineScheduler.java 92.3% <0%> (-2.57%) 6% <0%> (ø)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 93.23% <0%> (-1.94%) 2% <0%> (ø)
... and 26 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 e25be7c...8da1b86. Read the comment docs.

@akarnokd
Copy link
Member

Could you please restore the code coverage of SingleFromCallable? The new logic introduced a bunch of code paths that need testing.

Previously SingleFromCallable did not check if the subscriber was
unsubscribed before emitting onSuccess or onError. This fixes that
behavior and adds tests to SingleFromCallable, CompletableFromCallable,
and MaybeFromCallable.

Fixes ReactiveX#5742
@runningcode
Copy link
Contributor Author

Sounds good. I added a few tests by copying the logic from ObservableFromCallable.

@akarnokd akarnokd added this to the 2.2 milestone Nov 25, 2017
@akarnokd akarnokd merged commit 9564121 into ReactiveX:2.x Nov 25, 2017
@runningcode runningcode deleted the no/single-from-callable branch November 27, 2017 17:55
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.

2.x: SingleFromCallable doesn't check isDisposed before calling onError or onSuccess.
3 participants