New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in RightCurly with LITERAL_DO on do-while without curly braces #3681

Closed
romani opened this Issue Dec 30, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@romani
Member

romani commented Dec 30, 2016

$ cat config.xml 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
                        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
  <property name="charset" value="UTF-8"/>
  <property name="severity" value="warning"/>
  <module name="TreeWalker">
    <module name="RightCurly">
        <property name="tokens" value="LITERAL_DO"/>
    </module>
  </module>
</module>

$ javac LineGenerator.java 

$ cat LineGenerator.java 
public class LineGenerator {

    int limit;

    public void next() {
        do
            limit++;
        while (limit < 10);
    }
}

$ java -jar checkstyle-7.3-all.jar -c config.xml LineGenerator.java
Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing LineGenerator.java
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:287)
	at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:205)
	at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:425)
	at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:359)
	at com.puppycrawl.tools.checkstyle.Main.main(Main.java:174)
Caused by: java.lang.NullPointerException
	at com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.getDetails(RightCurlyCheck.java:373)
	at com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.visitToken(RightCurlyCheck.java:175)
	at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:361)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:498)
	at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:303)
	at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:178)
	at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:78)
	at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:307)
	at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:278)
	... 4 more
Checkstyle ends with 1 errors.

original code is http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/d966fc5a7be5/test/java/io/charStreams/LineGenerator.java#l59

@romani romani changed the title from NPE in RightCurly with LITERAL_DO on do-while wihtout curly braces to NPE in RightCurly with LITERAL_DO on do-while without curly braces Dec 30, 2016

@romani romani added the approved label Dec 30, 2016

rnveach added a commit to rnveach/checkstyle that referenced this issue Jan 5, 2017

rnveach added a commit to rnveach/checkstyle that referenced this issue Jan 5, 2017

@rnveach rnveach self-assigned this Jan 5, 2017

romani added a commit that referenced this issue Jan 5, 2017

@romani romani added the bug label Jan 5, 2017

@romani romani added this to the 7.5 milestone Jan 5, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jan 5, 2017

Member

fix is merged

Member

romani commented Jan 5, 2017

fix is merged

@romani romani closed this Jan 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment