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 |
| 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.
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.
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 :