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

Include classname of null-returning map function in NPE msg #2984

Conversation

ismailalammar
Copy link
Contributor

linked issue #2982

this PR include :

  • log class name in (FluxMap - FluxMapSignal - FluxMapFuseable) if mapper returns null.

@ismailalammar ismailalammar requested a review from a team as a code owner March 28, 2022 11:47
@pivotal-cla
Copy link

@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
@pivotal-cla
Copy link

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

@pivotal-cla
Copy link

@ismailalammar Thank you for signing the Contributor License Agreement!

@simonbasle
Copy link
Contributor

thanks @ismailalammar !
as I stated in the issue, this should have been opened against the 3.4.x branch.
you will need to git rebase -i 3.4.x and drop the commits that don't belong to the PR, then I can edit the PR target (or you can do it if you're familiar with the procedure).

Also, can you try to add tests for these in FluxMapTest and FluxMapSignalTest?
In FluxMapTest there is a mapperReturnsNull test but it is using an old style (no StepVerifier), doesn't assert the message of the NullPointerException and only covers a fused case.

@@ -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.");

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.");
}

Copy link
Contributor Author

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

@ismailalammar ismailalammar marked this pull request as draft March 28, 2022 22:43
@ismailalammar
Copy link
Contributor Author

thanks @ismailalammar ! as I stated in the issue, this should have been opened against the 3.4.x branch. you will need to git rebase -i 3.4.x and drop the commits that don't belong to the PR, then I can edit the PR target (or you can do it if you're familiar with the procedure).

Also, can you try to add tests for these in FluxMapTest and FluxMapSignalTest? In FluxMapTest there is a mapperReturnsNull test but it is using an old style (no StepVerifier), doesn't assert the message of the NullPointerException and only covers a fused case.

sure , will do

@ismailalammar ismailalammar force-pushed the dev-2982-to-log-classname-of-mapper-if-the-return-value-is-null branch from 2b2b20b to a5510cc Compare March 29, 2022 07:42
@ismailalammar ismailalammar changed the base branch from main to 3.4.x March 29, 2022 07:46
@simonbasle
Copy link
Contributor

@ismailalammar any progress on this? do you need help with writing the tests?

@He-Pin
Copy link
Contributor

He-Pin commented Apr 26, 2022

Can it rightly retrieve the lambda's line numbers too?

@simonbasle
Copy link
Contributor

simonbasle commented Apr 26, 2022

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

@ismailalammar
Copy link
Contributor Author

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

@simonbasle simonbasle added this to the 3.4.18 milestone May 5, 2022
@simonbasle simonbasle marked this pull request as ready for review May 5, 2022 09:46
@simonbasle simonbasle changed the title dev - 2982 - to log classname of mapper if it returns value is null Include classname of null-returning map function in NPE msg May 5, 2022
@simonbasle simonbasle merged commit e33211c into reactor:3.4.x May 5, 2022
@reactorbot
Copy link

@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 main 🙇

simonbasle added a commit that referenced this pull request May 5, 2022
@chemicL chemicL added the type/enhancement A general enhancement label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants