Skip to content

[java] Fix #7137: InvalidLogMessageFormat: handle unresolved exception type (incomplete auxclasspath) - #7160

Merged
adangel merged 3 commits into
pmd:mainfrom
KaustAbhinand:Fix-for-#7137
Oct 26, 2026
Merged

adangel merged 3 commits into
pmd:mainfrom
KaustAbhinand:Fix-for-#7137

Conversation

@KaustAbhinand

Copy link
Copy Markdown
Contributor

Describe the PR

This PR fixes issue #7137.
It wasn't much of a change, I had just introduced a new branch in the InvalidLogMessageRule.java (isThrowable method) that checks if the catch parameter is a throwable subtype. Even if the type is unresolveable.
The made the test code pass. I added it in the InvalidLogMessageFormat.xml file.

Related issues

Closes #7137

Ready?

Yes, according to me

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

@KaustAbhinand

Copy link
Copy Markdown
Contributor Author

@UncleOwen, please review the changes :)

@pmd-actions-helper

pmd-actions-helper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 16 errors and 9 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-10-26 15:13:10+00:00 for b44c8f3)

@zbynek

zbynek commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

The unit test added here confirms that the issue exists if the auxiliary classpath is not configured correctly and PMD cannot see the type hierarchy of the custom exception. The fix makes the code more robust in case the type information is missing. I'd suggest to update the PR description and the test description to reflect that.

@zbynek zbynek changed the title Fix for issue #7137. [java] [java] InvalidLogMessageFormat false positive when if/else block in the catch block Oct 19, 2026
@adangel adangel changed the title [java] InvalidLogMessageFormat false positive when if/else block in the catch block [java] Fix #7137: InvalidLogMessageFormat false positive when if/else block in the catch block Oct 26, 2026
@adangel adangel added the in:type-resolution Affects the type resolution code label Oct 26, 2026
@adangel adangel added this to the 7.29.0 milestone Oct 26, 2026

@adangel adangel 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, looks good.

I think, this makes a reasonable improvement for the case, that PMD is called wrongly (without the correct auxclasspath). The catch parameter must be of type throwable, so this assumption is pretty safe.

@adangel adangel changed the title [java] Fix #7137: InvalidLogMessageFormat false positive when if/else block in the catch block [java] Fix #7137: InvalidLogMessageFormat: handle unresolved exception type (incomplete auxclasspath) Oct 26, 2026
@adangel
adangel merged commit 817b8cd into pmd:main Oct 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:type-resolution Affects the type resolution code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath)

3 participants