Menu

#1482 PMD randomly fails with NPE

PMD-5.4.2
duplicate
None
PMD
3-Major
Bug
5.4.1
2016-05-21
2016-05-17
krzyk
No

I'm not sure if this problem is with PMD itself or maven pmd plugin, but sometimes I get following errors:

WARNING: Exception applying rule TooManyFields on file /path/to/DefaultInstanceId.java, continuing with next rule
java.lang.NullPointerException
    at net.sourceforge.pmd.lang.java.rule.codesize.TooManyFieldsRule.visit(TooManyFieldsRule.java:55)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.visitAll(AbstractJavaRule.java:31)
    at net.sourceforge.pmd.lang.java.rule.AbstractJavaRule.apply(AbstractJavaRule.java:25)
    at net.sourceforge.pmd.lang.rule.AbstractDelegateRule.apply(AbstractDelegateRule.java:215)
    at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:307)
    at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:125)
    at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:146)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:76)
    at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:43)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:79)
    at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:25)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

The class in question is quite simple:

public class DefaultInstanceId implements InstanceId {

    private final String instanceId;

    public DefaultInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    @Override
    public String get() {
        return instanceId;
    }
}

This error happens only sometimes so it is quite frustrating to see that the PMD doesn't complain and then complains when the source code didn't change at all.
The mvn build is run without

Discussion

  • krzyk

    krzyk - 2016-05-17

    Also, it doesn't always fail on this class, sometimes it is different, but always in the same module. As if some class in there caused PMD to behave irrationally.

     
  • Andreas Dangel

    Andreas Dangel - 2016-05-21
    • status: open --> duplicate
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.4.2
     

Log in to post a comment.

Monday.com Logo