-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -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"))); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about this one?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.") |
There was a problem hiding this comment.
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 @Ignore
d tests in this PR?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @akarnokd
This PR adds null checks to places where it was missing.
In addition, the
XMapNotification
operators now report a composite exception of the originalThrowable
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.