You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath) #7137
Description:
Using log4j in some cases PMD gives false positives. I think the problem is in if / else inside catch block.
In one case the code uses
voiderror(Stringmessage, Objectp0);
and in the other case
voiderror(Stringmessage, Throwablethrowable);
Code Sample demonstrating the issue:
catch ( CustomerKickoutExceptionckE ) {
if ( isDeploymentTypeProduction() ) {
logger.error( "Kickout error: {}", ckE.toString() );
} else {
logger.error( "Kickout error:", ckE ); // <-- Too many arguments, expected 0 argument but found 1.
}
Expected outcome:
The code in the else block uses correct void error(String message, Throwable throwable); overloaded method of this function and it should not be marked
changed the title [-]InvalidLogMessageFormat false possitive when if/else blocck in the catch block[/-][+][java] InvalidLogMessageFormat false positive when if/else block in the catch block[/+]on Oct 5, 2026
@piotridzikowski are you sure you configured the aux classpath for PMD analysis correctly? Specifically, CustomerKickoutException and all its superclasses should be visible to PMD.
so it's very likely that CustomerKickoutException is not visible to PMD, resulting in the false positive. Is it defined in the same library/project as the code you're validating using PMD? Could you reduce your testcase into a minimal reproducble example.
changed the title [-][java] InvalidLogMessageFormat false positive when if/else block in the catch block[/-][+][java] InvalidLogMessageFormat: false positive when if/else block in the catch block[/+]on Oct 26, 2026
changed the title [-][java] InvalidLogMessageFormat: false positive when if/else block in the catch block[/-][+][java] InvalidLogMessageFormat: false positive for unresolved exception type (incomplete auxclasspath)[/+]on Oct 26, 2026
changed the title [-][java] InvalidLogMessageFormat: false positive for unresolved exception type (incomplete auxclasspath)[/-][+][java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath)[/+]on Oct 29, 2026
Activity
KaustAbhinand commentedon Oct 4, 2026
Hi has anyone opened a PR for this? If not, i would like to take it up :)
UncleOwen commentedon Oct 4, 2026
@KaustAbhinand No, there isn't a PR for this, yet. Go ahead!
(If there was a PR for this, you'd see it on the right under "Development")
[-]InvalidLogMessageFormat false possitive when if/else blocck in the catch block[/-][+][java] InvalidLogMessageFormat false positive when if/else block in the catch block[/+]KaustAbhinand commentedon Oct 7, 2026
Hi @UncleOwen! I have opened a PR, please review it.
zbynek commentedon Oct 18, 2026
@piotridzikowski are you sure you configured the aux classpath for PMD analysis correctly? Specifically,
CustomerKickoutExceptionand all its superclasses should be visible to PMD.piotridzikowski commentedon Oct 20, 2026
zbynek commentedon Oct 21, 2026
Interesting, the following code has no violations of this rule, as expected:
so it's very likely that
CustomerKickoutExceptionis not visible to PMD, resulting in the false positive. Is it defined in the same library/project as the code you're validating using PMD? Could you reduce your testcase into a minimal reproducble example.[-][java] InvalidLogMessageFormat false positive when if/else block in the catch block[/-][+][java] InvalidLogMessageFormat: false positive when if/else block in the catch block[/+]adangel commentedon Oct 26, 2026
It's definitely auxclasspath problem, as the fix/PR clearly says "unresolved type"...
[-][java] InvalidLogMessageFormat: false positive when if/else block in the catch block[/-][+][java] InvalidLogMessageFormat: false positive for unresolved exception type (incomplete auxclasspath)[/+][java] Fix pmd#7137: InvalidLogMessageFormat: handle unresolved excep…
[-][java] InvalidLogMessageFormat: false positive for unresolved exception type (incomplete auxclasspath)[/-][+][java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath)[/+]