[java] InvalidLogMessageFormat FP with StringFormattedMessage and ParameterizedMessage #3133
Labels
a:false-positive
PMD flags a piece of code that is not problematic
Milestone
Affects PMD Version: 6.31
Rule: InvalidLogMessageFormat
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/pmd-6.31.0/pmd_rules_java_errorprone.html#invalidlogmessageformat
Description:
In Log4j documents(https://logging.apache.org/log4j/2.x/manual/messages.html),
ParameterizedMessage
andStringFormattedMessage
are described.However, PMD shows alarms for it.
Also, even if there are no place holder with
Throwable
type in parameter, it shows an alarm.Case 1. shows
StringFormattedMessage
,Case 2. shows
ParameterizedMessage
and no place holder examplewhich are from brooklyn-server project in Apach Software Foundation.
Please, check them.
Thank you.
Code Sample demonstrating the issue:
Case 1.
Detection message:
TestInvalidLogMessageFormat.java:7: InvalidLogMessageFormat: Too many arguments, expected 0 argument but have 1
Case 2.
brooklyn-server/core/src/main/java/org/apache/brooklyn/core/feed/AttributePollHandler.java:167: InvalidLogMessageFormat: Too many arguments, expected 0 argument but have 1
brooklyn-server/core/src/main/java/org/apache/brooklyn/core/feed/AttributePollHandler.java:183: InvalidLogMessageFormat: Too many arguments, expected 0 argument but have 1
brooklyn-server/core/src/main/java/org/apache/brooklyn/core/feed/AttributePollHandler.java:186: InvalidLogMessageFormat: Missing arguments, expected 4 arguments but have 1
Expected outcome:
No Alarms.
Running PMD through: [CLI]
The text was updated successfully, but these errors were encountered: