Menu

#1345 UseCollectionIsEmpty throws NullPointerException

PMD-5.3.2
closed
None
PMD
3-Major
Bug
5.3.1
2015-05-09
2015-05-06
No

PMD prints "Exception applying rule UseCollectionIsEmpty" when analyzing the attached java file.

The top of the printed stacktrace:

  [pmd] java.lang.NullPointerException
  [pmd]     at net.sourceforge.pmd.lang.ast.AbstractNode.jjtGetChild(AbstractNode.java:90)
  [pmd]     at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.checkComparison(AbstractInefficientZeroCheck.java:129)
  [pmd]     at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.isCompare(AbstractInefficientZeroCheck.java:108)
  [pmd]     at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.checkNodeAndReport(AbstractInefficientZeroCheck.java:88)
  [pmd]     at net.sourceforge.pmd.lang.java.rule.AbstractInefficientZeroCheck.visit(AbstractInefficientZeroCheck.java:71)
  [pmd]     at net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId.jjtAccept(ASTVariableDeclaratorId.java:29)
1 Attachments

Discussion

  • Ville Oikarinen

    Ville Oikarinen - 2015-05-06

    So, there is no crash if "this." is removed from the method call the collection size is compared to.

     
  • Andreas Dangel

    Andreas Dangel - 2015-05-09
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.3.2
     

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.