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
When using StructuredArguments, it may be normal to have additional arguments to the ones used directly in the message format. With such situations, the InvalidLogMessageFormat rule may throw a NPE when trying to remove the last parameter if it is a Throwable.
The instruction decl.getName().equals(varName) in isLambdaParameter() doesn't check that decl.getName() doesn't return null.
Exception Stacktrace:
Exception applying rule InvalidLogMessageFormat on file xxx.java, continuing with next rule
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "net.sourceforge.pmd.lang.symboltable.NameDeclaration.getName()" is null
at net.sourceforge.pmd.lang.java.rule.errorprone.InvalidLogMessageFormatRule.isLambdaParameter(InvalidLogMessageFormatRule.java:249)
at net.sourceforge.pmd.lang.java.rule.errorprone.InvalidLogMessageFormatRule.removeThrowableParam(InvalidLogMessageFormatRule.java:231)
at net.sourceforge.pmd.lang.java.rule.errorprone.InvalidLogMessageFormatRule.visit(InvalidLogMessageFormatRule.java:164)
at net.sourceforge.pmd.lang.java.ast.ASTName.jjtAccept(ASTName.java:38)
at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visitAll(AbstractJavaRule.java:164)
at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:158)
at net.sourceforge.pmd.lang.internal.DefaultRulechainVisitor.visit(DefaultRulechainVisitor.java:26)
at net.sourceforge.pmd.lang.rule.AbstractRuleChainVisitor.visitAll(AbstractRuleChainVisitor.java:101)
at net.sourceforge.pmd.RuleChain.apply(RuleChain.java:72)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:160)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:209)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:118)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:100)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:62)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:85)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:29)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Affects PMD Version: 6.51.0
Description:
When using StructuredArguments, it may be normal to have additional arguments to the ones used directly in the message format. With such situations, the InvalidLogMessageFormat rule may throw a NPE when trying to remove the last parameter if it is a Throwable.
The instruction
decl.getName().equals(varName)
inisLambdaParameter()
doesn't check thatdecl.getName()
doesn't return null.Exception Stacktrace:
Code Sample demonstrating the issue:
Steps to reproduce:
Just running
./gradlew build
Running PMD through: Gradle
The text was updated successfully, but these errors were encountered: