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: add missing null checks on values returned by user functions #5379

Merged
merged 1 commit into from
Jun 1, 2017

Conversation

akarnokd
Copy link
Member

This PR adds null checks to places where it was missing.

In addition, the XMapNotification operators now report a composite exception of the original Throwable and the error thrown by the function that should return the continuation source.

Also fixed TestSubscriber/TestObserver not cancelling the sequence if the fused poll crashed.

@akarnokd akarnokd added this to the 2.0 backlog milestone May 30, 2017
@codecov
Copy link

codecov bot commented May 30, 2017

Codecov Report

Merging #5379 into 2.x will decrease coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5379      +/-   ##
============================================
- Coverage     96.17%   96.08%   -0.09%     
+ Complexity     5789     5778      -11     
============================================
  Files           630      630              
  Lines         41189    41195       +6     
  Branches       5726     5726              
============================================
- Hits          39613    39582      -31     
- Misses          624      639      +15     
- Partials        952      974      +22
Impacted Files Coverage Δ Complexity Δ
...ctivex/internal/operators/maybe/MaybeZipArray.java 97.36% <100%> (ø) 6 <0> (ø) ⬇️
...internal/operators/observable/ObservableUsing.java 96.1% <100%> (ø) 2 <0> (ø) ⬇️
...ators/observable/ObservableWithLatestFromMany.java 99.2% <100%> (ø) 7 <0> (ø) ⬇️
...operators/flowable/FlowableWithLatestFromMany.java 97.69% <100%> (ø) 7 <0> (ø) ⬇️
...operators/observable/ObservableInternalHelper.java 89.25% <100%> (+0.18%) 18 <0> (ø) ⬇️
...al/operators/flowable/FlowableMapNotification.java 100% <100%> (ø) 2 <0> (ø) ⬇️
...nternal/operators/observable/ObservableReplay.java 97.77% <100%> (+0.83%) 22 <0> (-1) ⬇️
...vex/internal/operators/maybe/MaybeZipIterable.java 100% <100%> (ø) 9 <0> (ø) ⬇️
...main/java/io/reactivex/observers/TestObserver.java 100% <100%> (ø) 50 <0> (ø) ⬇️
...x/internal/operators/single/SingleZipIterable.java 100% <100%> (ø) 9 <0> (ø) ⬇️
... and 52 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 8240d5c...d24bea7. Read the comment docs.

@@ -319,7 +320,7 @@ public boolean test(Notification<Object> t) throws Exception {
@Override
public Observable<R> apply(T t) throws Exception {
return RxJavaPlugins.onAssembly(new SingleToObservable<R>(
ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null value")));
ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null SingleSource")));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't it Observable / ObservableSource?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just open the collapsed section and see what mapper is: final Function<? super T, ? extends SingleSource<? extends R>> mapper;

@@ -142,6 +142,7 @@ public void onNext(T t) {
} catch (Throwable ex) {
// Exceptions.throwIfFatal(e); TODO add fatal exceptions?
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still undecided.

@@ -264,7 +264,7 @@ public void testFlatMapTransformsOnErrorFuncThrows() {

source.flatMap(just(onNext), funcThrow((Throwable) null, onError), just0(onComplete)).subscribe(o);

verify(o).onError(any(TestException.class));
verify(o).onError(any(CompositeException.class));
Copy link
Collaborator

Choose a reason for hiding this comment

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

verify that the exceptions are in right order within the CompositeException?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tested separately in the FlowableMapNotificationTest.java additions.

@@ -1341,6 +1341,7 @@ public void flatMapNotificationOnErrorNull() {
}

@Test(expected = NullPointerException.class)
@Ignore("No longer crashes with NPE but signals it; tested elsewhere.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there reasons to keep @Ignored tests in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had two options: I remove it and I get a question on why or ignore it with comments and get a question why...

Copy link
Contributor

Choose a reason for hiding this comment

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

Haha :D

But now you have explanation in GitHub history so maybe remove them?

Copy link
Member Author

Choose a reason for hiding this comment

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

First it has to get into the 2.x branch for that. Otherwise, there could be a purge of ignored unit test in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I remove it and I get a question on why or ignore it with comments and get a question why...

I like this way of thinking. :D

Copy link
Collaborator

@davidmoten davidmoten left a comment

Choose a reason for hiding this comment

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

Thanks @akarnokd

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.

4 participants