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

A “NullPointerException” could be thrown; “ofNullable()” can return null #5046

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

reda-alaoui
Copy link

@reda-alaoui reda-alaoui commented Feb 28, 2025

Reproducer + hacky fix for https://community.sonarsource.com/t/a-nullpointerexception-could-be-thrown-ofnullable-can-return-null/134892 .

The hacky fix breaks org.sonar.java.checks.ChangeMethodContractCheckTest#test.

IMHO, nullable annotations on method generic return parameters are structurally wrongly implemented. A nullable annotation on the return type or a generic element of the return type is viewed as the same by the analyzer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant