Skip to content
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

EmptyForInitializerPad: ArrayIndexOutOfBoundsException #12291

Closed
rnveach opened this issue Oct 10, 2022 · 1 comment · Fixed by #12310
Closed

EmptyForInitializerPad: ArrayIndexOutOfBoundsException #12291

rnveach opened this issue Oct 10, 2022 · 1 comment · Fixed by #12310

Comments

@rnveach
Copy link
Member

rnveach commented Oct 10, 2022

Identified at #12277 ,

$ cat TestClass.java
public class TestClass {
    void method() {
for (
;;) {}
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
         <module name="EmptyForInitializerPad">
         </module>
    </module>
</module>

$ java -jar checkstyle-10.3.4-all.jar -c TestConfig.xml TestClass.java
Starting audit...
com.puppycrawl.tools.checkstyle.api.CheckstyleException: Exception was thrown while processing TestClass.java
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:307)
    at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:224)
    at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:416)
    at com.puppycrawl.tools.checkstyle.Main.runCli(Main.java:339)
    at com.puppycrawl.tools.checkstyle.Main.execute(Main.java:196)
    at com.puppycrawl.tools.checkstyle.Main.main(Main.java:131)
Caused by: java.lang.ArrayIndexOutOfBoundsException: origin(0) > fence(-1)
    at java.base/java.util.Spliterators.checkFromToBounds(Spliterators.java:387)
    at java.base/java.util.Spliterators.spliterator(Spliterators.java:239)
    at java.base/java.util.Arrays.spliterator(Arrays.java:5521)
    at java.base/java.util.Arrays.stream(Arrays.java:5663)
    at com.puppycrawl.tools.checkstyle.utils.CodePointUtil.hasWhitespaceBefore(CodePointUtil.java:54)
    at com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck.visitToken(EmptyForInitializerPadCheck.java:157)
    at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:336)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:407)
    at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:274)
    at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:155)
    at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:98)
    at com.puppycrawl.tools.checkstyle.Checker.processFile(Checker.java:335)
    at com.puppycrawl.tools.checkstyle.Checker.processFiles(Checker.java:294)
    ... 5 more
Checkstyle ends with 1 errors.

I am expecting no violation.

@pbludov
Copy link
Member

pbludov commented Nov 1, 2022

Fix is merged.

nrmancuso pushed a commit to nrmancuso/checkstyle that referenced this issue Nov 3, 2022
nrmancuso pushed a commit to nrmancuso/checkstyle that referenced this issue Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants