-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I'm still undecided. |
||
errors.add(ex); | ||
qs.dispose(); | ||
} | ||
return; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1341,6 +1341,7 @@ public Publisher<Integer> call() { | |
} | ||
|
||
@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 commentThe reason will be displayed to describe this comment to others. Learn more. Are there reasons to keep There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more.
I like this way of thinking. :D |
||
public void flatMapNotificationOnErrorReturnsNull() { | ||
Flowable.error(new TestException()).flatMap(new Function<Object, Publisher<Integer>>() { | ||
@Override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Tested separately in the FlowableMapNotificationTest.java additions. |
||
verify(o, never()).onNext(any()); | ||
verify(o, never()).onComplete(); | ||
} | ||
|
@@ -997,4 +997,40 @@ public void run() { | |
} | ||
} | ||
} | ||
|
||
@Test | ||
public void iterableMapperFunctionReturnsNull() { | ||
Flowable.just(1) | ||
.flatMapIterable(new Function<Integer, Iterable<Object>>() { | ||
@Override | ||
public Iterable<Object> apply(Integer v) throws Exception { | ||
return null; | ||
} | ||
}, new BiFunction<Integer, Object, Object>() { | ||
@Override | ||
public Object apply(Integer v, Object w) throws Exception { | ||
return v; | ||
} | ||
}) | ||
.test() | ||
.assertFailureAndMessage(NullPointerException.class, "The mapper returned a null Iterable"); | ||
} | ||
|
||
@Test | ||
public void combinerMapperFunctionReturnsNull() { | ||
Flowable.just(1) | ||
.flatMap(new Function<Integer, Publisher<Object>>() { | ||
@Override | ||
public Publisher<Object> apply(Integer v) throws Exception { | ||
return null; | ||
} | ||
}, new BiFunction<Integer, Object, Object>() { | ||
@Override | ||
public Object apply(Integer v, Object w) throws Exception { | ||
return v; | ||
} | ||
}) | ||
.test() | ||
.assertFailureAndMessage(NullPointerException.class, "The mapper returned a null Publisher"); | ||
} | ||
} |
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;