Skip to content

[java] Fix #6900: Modifies isNullCheck to accept negated expressions - #6917

Merged
UncleOwen merged 9 commits into
pmd:mainfrom
Will-6543:issue-6900
Aug 4, 2026
Merged

UncleOwen merged 9 commits into
pmd:mainfrom
Will-6543:issue-6900

Conversation

@Will-6543

@Will-6543 Will-6543 commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Describe the PR

Removes false negative by first stripping negations from expressions passed to isNullCheck before performing the original check.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@pmd-actions-helper

pmd-actions-helper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

⚠️ Running pmdtester failed, this message is mainly used to remind the maintainers of PMD.

(comment created at 2026-08-04 13:38:29+00:00 for c65a219)

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@UncleOwen
UncleOwen merged commit 55d2cca into pmd:main Aug 4, 2026
9 checks passed
@UncleOwen UncleOwen added this to the 7.27.0 milestone Aug 4, 2026
@Will-6543
Will-6543 deleted the issue-6900 branch August 4, 2026 13:40
Will-6543 added a commit to Will-6543/pmd that referenced this pull request Oct 7, 2026
…ns (pmd#6917)

* strip negations from around an expression before check

* resolved endless loop

* resolved code style issue

* added unit tests for nullCheck

* fixed bad tests

* fixes style violations and targets tests at non-overloaded method

* Added full negation testcase

* Added nested negation testcase

* added issue to release notes
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.

[java] DoubleCheckedLocking: False negative when the outer null check is written as !(x != null)

2 participants