Menu

#1384 NullPointerException in ConsecutiveLiteralAppendsRule

PMD-5.3.4
closed
None
PMD
3-Major
Bug
5.3.3
ConsecutiveLiteralAppendsRule
2015-09-20
2015-07-26
No

I updated from 5.3.2 to 5.3.3 and now I get this NullPointerException.

Exception applying rule ConsecutiveLiteralAppends on file <snip path="">\CatalogHandler.java, continuing with next rule
java.lang.NullPointerException
at net.sourceforge.pmd.lang.java.rule.strings.ConsecutiveLiteralAppendsRule.checkInitializerExpressions(Consecut
iveLiteralAppendsRule.java:195)
at net.sourceforge.pmd.lang.java.rule.strings.ConsecutiveLiteralAppendsRule.visit(ConsecutiveLiteralAppendsRule.
java:93)

1 Attachments

Related

Issues: #1389

Discussion

  • Patrick McEvoy

    Patrick McEvoy - 2015-07-26

    It happens when the StringBuilder is declared as a member variable but not instantiated until the constructor.

    Example to reproduce the problem.
    public class ConsecutiveLiteralAppendsRuleTest {
    private StringBuilder cdata;
    }

     
  • Toby Willcock

    Toby Willcock - 2015-07-27

    The following produces the same NullPointerException in 5.3.3 too:

    public class ConsecutiveLiteralAppendsRuleTest {
        public void appendChar(final StringBuilder s) {
            // do nothing
        }
    }
    
     

    Last edit: Toby Willcock 2015-07-27
  • Andreas Dangel

    Andreas Dangel - 2015-08-01
    • status: open --> closed
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-5.3.4
     
  • Juan Sotuyo

    Juan Sotuyo - 2015-09-09

    Awesome! Any schedule for 5.3.4 / 5.4.0?

     
  • Andreas Dangel

    Andreas Dangel - 2015-09-20

    I release 5.3.4 this weekend and plan to release 5.4.0 in two weeks or so...

     

Log in to post a comment.