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

Make NP Dereference hint aware of Objects.requireNonNull(). #6195

Merged
merged 2 commits into from
Jul 16, 2023

Conversation

mbien
Copy link
Member

@mbien mbien commented Jul 13, 2023

The first commit is fixing the test framework itself since some tests were using the assertNotContainsWarnings wrong.

assertContainsWarnings checks against toString() which is the full error state, including line number and position.
assertNotContainsWarnings is only checking getDescription(), but the doc was copied from assertContainsWarnings which means that all tests which actually followed the doc, didn't verify anything.

second commit makes the NPECheck hint Objects.requireNonNull aware.

fixes #6149

Method checked against getDescription() instead of toString() as the
doc specifies, which made this assert essentially a no-op.

The method assertContainsWarnings() does also check against toString().
@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) hints labels Jul 13, 2023
@mbien mbien added this to the NB19 milestone Jul 13, 2023
@mbien mbien requested a review from jlahoda July 13, 2023 23:15
@mbien mbien force-pushed the dereference-hint-requirenonnull branch from 1e131bb to 0498a03 Compare July 13, 2023 23:18
@mbien
Copy link
Member Author

mbien commented Jul 15, 2023

panning to merge this too on Sunday before freeze. Is a fairly low risk fix.

@mbien mbien merged commit 97d51b1 into apache:master Jul 16, 2023
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hints Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Objects.requireNonNull should disable "Null Pointer Dereference" warnings
1 participant