-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Include classname of null-returning map
function in NPE msg
#2984
Include classname of null-returning map
function in NPE msg
#2984
Conversation
@ismailalammar Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
1 similar comment
@ismailalammar Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@ismailalammar Thank you for signing the Contributor License Agreement! |
thanks @ismailalammar ! Also, can you try to add tests for these in |
@@ -104,7 +104,7 @@ public void onNext(T t) { | |||
|
|||
try { | |||
v = Objects.requireNonNull(mapper.apply(t), | |||
"The mapper returned a null value."); | |||
"The mapper [" + mapper.getClass().getName() + "] returned a null value."); |
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.
For better performance, we can concat the strings only after checking the return value is null. e.g.:
Object value = mapper.apply(t);
if (value == null) {
throw new NullPointerException("The mapper [" + mapper.getClass().getName() + "] returned a null value.");
}
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.
sure will change it , thanks @JamesChenX
sure , will do |
2b2b20b
to
a5510cc
Compare
@ismailalammar any progress on this? do you need help with writing the tests? |
Can it rightly retrieve the lambda's line numbers too? |
I would rather rely on Java 14+ "better NPE" feature. Here there isn't really a lambda line to communicate, because the lambda itself doesn't throw, it merely returns |
i am so sorry i missed this ticket , got blocked with amount of work in the past few weeks. i don't think i will be able to complete the test cases in the near future . apologize for that |
map
function in NPE msg
@simonbasle this PR seems to have been merged on a maintenance branch, please ensure the change is merge-forwarded to intermediate maintenance branches and up to |
linked issue #2982
this PR include :