GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath) · Issue #7137 · pmd/pmd

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

New issue
Copy link
New issue
Copy link
Closed
#7160
Closed
[java] InvalidLogMessageFormat: False positive for unresolved exception type (incomplete auxclasspath)#7137
#7160
Copy link
Labels
a:false-positivePMD flags a piece of code that is not problematicin:type-resolutionAffects the type resolution code
Milestone
7.29.0

Description

@piotridzikowski
piotridzikowski
opened on Oct 2, 2026
Issue body actions

Affects PMD Version:
7.28.0
Rule: InvalidLogMessageFormat

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

void error(String message, Object p0);

and in the other case

void error(String message, Throwable throwable);

Code Sample demonstrating the issue:

catch ( CustomerKickoutException ckE ) {
				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

Running PMD through: ANT

Activity

  1. piotridzikowski
    added
    a:false-positivePMD flags a piece of code that is not problematic
    on Oct 2, 2026
  2. KaustAbhinand commented on Oct 4, 2026

    @KaustAbhinand
    KaustAbhinand
    on Oct 4, 2026
    Contributor
    More actions

    Hi has anyone opened a PR for this? If not, i would like to take it up :)

  3. UncleOwen commented on Oct 4, 2026

    @UncleOwen
    UncleOwen
    on Oct 4, 2026
    Member
    More actions

    @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")

  4. UncleOwen
    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
  5. KaustAbhinand commented on Oct 7, 2026

    @KaustAbhinand
    KaustAbhinand
    on Oct 7, 2026
    Contributor
    More actions

    Hi @UncleOwen! I have opened a PR, please review it.

  6. zbynek commented on Oct 18, 2026

    @zbynek
    zbynek
    on Oct 18, 2026
    Contributor
    More actions

    @piotridzikowski are you sure you configured the aux classpath for PMD analysis correctly? Specifically, CustomerKickoutException and all its superclasses should be visible to PMD.

    • https://pmd.github.io/pmd/pmd_languages_java.html#providing-the-auxiliary-classpath
    • https://pmd.github.io/pmd/pmd_userdocs_tools_ant.html
  7. piotridzikowski commented on Oct 20, 2026

    @piotridzikowski
    piotridzikowski
    on Oct 20, 2026 via email
    Author
    More actions
    Hi, Yes, for me it looks like the auxclasspath is correct.
    …
    On Sun, Oct 18, 2026 at 5:02 PM Zbynek Konecny ***@***.***> wrote: *zbynek* left a comment (pmd/pmd#7137) <#7137 (comment)> @piotridzikowski <https://github.com/piotridzikowski> are you sure you configured the aux classpath for PMD analysis correctly? Specifically, CustomerKickoutException and all its superclasses should be visible to PMD. - https://pmd.github.io/pmd/pmd_languages_java.html#providing-the-auxiliary-classpath - https://pmd.github.io/pmd/pmd_userdocs_tools_ant.html — Reply to this email directly, view it on GitHub <#7137?email_source=notifications&email_token=AASM74XOWYBBXDHWSITCOML5UTLOXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRVGE2DCMJVGMZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6251411532>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AASM74QNHRRG3ZFPLQC2TP35UTLOXAVCNFSNUABDKJSXA33TNF2G64TZHM2DSOJSHEYDMO2JONZXKZJ3GU3DOOBZGMYTEMRSUF3AE> . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS <https://github.com/notifications/mobile/ios/AASM74UWODZDZRXWSO3GXP35UTLOXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRVGE2DCMJVGMZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y> and Android <https://github.com/notifications/mobile/android/AASM74QHYQH44YXRAST3JJT5UTLOXA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMMRVGE2DCMJVGMZKM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI>. Download it today! You are receiving this because you were mentioned.Message ID: ***@***.***>
  8. zbynek commented on Oct 21, 2026

    @zbynek
    zbynek
    on Oct 21, 2026
    Contributor
    More actions

    Interesting, the following code has no violations of this rule, as expected:

    import org.apache.logging.log4j.Logger;
    import org.apache.logging.log4j.LogManager;
    
    public class Bug {
        private static final Logger logger = LogManager.getLogger();
    
        public void test() {
            try {
                generateMessage();
            } catch ( CustomerKickoutException ckE) {
                if ( isDeploymentTypeProduction() ) {
                    logger.error( "Kickout error: {}", ckE.toString() );
                } else {
                    logger.error( "Kickout error:", ckE );
                }
            }
        }
        private boolean isDeploymentTypeProduction() { return false; }
        private String generateMessage() throws CustomerKickoutException {
            if (1 < 0) {
                throw new CustomerKickoutException();
            }
            return "message";
        }
    
        private class CustomerKickoutException extends Exception {}
    }

    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.

  9. adangel
    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
  10. adangel commented on Oct 26, 2026

    @adangel
    adangel
    on Oct 26, 2026
    Member
    More actions

    It's definitely auxclasspath problem, as the fix/PR clearly says "unresolved type"...

  11. adangel
    added
    in:type-resolutionAffects the type resolution code
    on Oct 26, 2026
  12. adangel
    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
  13. adangel
    added this to the 7.29.0 milestone on Oct 26, 2026
  14. adangel
    closed this as completedin #7160on Oct 26, 2026
  15. adangel
    added a commit that references this issue on Oct 26, 2026

    [java] Fix pmd#7137: InvalidLogMessageFormat: handle unresolved excep…

    This issue will close once commit 817b8cd is merged into the 'main' branch.
    817b8cd
  16. adangel
    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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:false-positivePMD flags a piece of code that is not problematicin:type-resolutionAffects the type resolution code

    Type

    No type

    Projects

    No projects

      Milestone

      • 7.29.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.