Menu

#1541 [java] InvalidSlf4jMessageFormat: False positive with placeholder and exception

PMD-5.5.3
closed
PMD
3-Major
Bug
5.5.2
InvalidSlf4jMessageFormat
2016-12-03
2016-11-10
Geniy00
No

similar to [#1500]

public static void main(String[] args) {
        try {
            ...
        } catch (Exception e) {
            log.error("Arg1 = {}. Exception: {}", "arg1Value", e);
        }
    }

I got false positive violation:

Missing arguments, expected 2 arguments but have 1

I ran it via gradle. I'll provide more information if you need.

Related

Issues: #1500

Discussion

  • Geniy00

    Geniy00 - 2016-11-10

    Pay attention, that issue is valid for cases when I got some field from exception instance or cast it to another exception.

     
  • Andreas Dangel

    Andreas Dangel - 2016-12-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -similar to https://sourceforge.net/p/pmd/bugs/1500/
    +similar to [#1500]
    
     ~~~
     public static void main(String[] args) {
    
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.5.3
     

    Related

    Issues: #1500

  • Andreas Dangel

    Andreas Dangel - 2016-12-03

    You can workaround this issue, if you do not put the Exception as last argument, e.g. just swapping arg1Value and e avoids this false positive.

     
  • Andreas Dangel

    Andreas Dangel - 2016-12-03
    • labels: --> java, java-logging-java
     
  • Andreas Dangel

    Andreas Dangel - 2016-12-03
    • status: in-progress --> closed
     
  • Andreas Dangel

    Andreas Dangel - 2016-12-03

    This bug will be fixed with PMD 5.5.3 and later.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.