StringIndexOutOfBoundsException

230 views
Skip to first unread message

Ahmed Ashour

unread,
Sep 3, 2015, 12:58:37 PM9/3/15
to checkstyle
Hi all,

With version 6.10.1, the far below exception happens.

Source code of the project can be found in [1].

Appreciate providing feedback about the reason.

Thanks a lot,

Ahmed


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle (default-cli) on project htmlunit: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle failed: String index out of range: -1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle (default-cli) on project htmlunit: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle failed: String index out of range: -1
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.apache.maven.plugins:maven-checkstyle-plugin:2.16:checkstyle failed: String index out of range: -1
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:203)
at java.lang.StringBuilder.charAt(StringBuilder.java:72)
at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.trimTail(JavadocStyleCheck.java:315)
at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.getCommentText(JavadocStyleCheck.java:269)
at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkFirstSentenceEnding(JavadocStyleCheck.java:230)
at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkComment(JavadocStyleCheck.java:207)
at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.visitToken(JavadocStyleCheck.java:148)
at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:392)
at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:503)
at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:334)
at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:209)
at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:265)
at org.apache.maven.plugin.checkstyle.exec.DefaultCheckstyleExecutor.executeCheckstyle(DefaultCheckstyleExecutor.java:252)
at org.apache.maven.plugin.checkstyle.AbstractCheckstyleReport.executeReport(AbstractCheckstyleReport.java:473)
at org.apache.maven.plugin.checkstyle.CheckstyleReport.executeReport(CheckstyleReport.java:154)
at org.apache.maven.reporting.AbstractMavenReport.generate(AbstractMavenReport.java:255)
at org.apache.maven.reporting.AbstractMavenReport.execute(AbstractMavenReport.java:143)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
... 20 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
Process exited with code 1

Roman Ivanov

unread,
Sep 3, 2015, 1:15:32 PM9/3/15
to Ahmed Ashour, checkstyle

Please find a single file that cause a problem and reproduce problem by our CLI to avoid any maven plugin effects.

http://checkstyle.sourceforge.net/cmdline.html#Download_and_Run

--
You received this message because you are subscribed to the Google Groups "checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to checkstyle+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ahmed Ashour

unread,
Sep 3, 2015, 2:52:52 PM9/3/15
to checkstyle, asas...@yahoo.com
Thanks, posted as #2094.

As a side note, it would be better if checkstyle prints the offending file name, instead of having the users to build checkstyle with logging details.

Yours,
Ahmed

Roman Ivanov

unread,
Sep 3, 2015, 3:36:04 PM9/3/15
to Ahmed Ashour, checkstyle
it depends on output format.

you run through maven plugin , that is another project and another maintenance team, please file an issue against checkstyle-maven-plugin.
our CLI do report path to problematic file.

--

Ahmed Ashour

unread,
Sep 3, 2015, 4:17:28 PM9/3/15
to Roman Ivanov, checkstyle
>> our CLI do report path to problematic file.

I have to argue this is not the case here:


>java -jar checkstyle-6.10.1-all.jar -c sun_checks.xml *.java
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.AbstractStringBuilder.charAt(Unknown Source)
        at java.lang.StringBuilder.charAt(Unknown Source)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.trimTail(JavadocStyleCheck.java:315)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.getCommentText(JavadocStyleCheck.java:269)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkFirstSentenceEnding(JavadocStyleCheck.java:230)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkComment(JavadocStyleCheck.java:207)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.visitToken(JavadocStyleCheck.java:148)
        at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:392)
        at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:503)
        at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:334)
        at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:209)
        at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
        at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:265)
        at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:271)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:121)


From: Roman Ivanov <romani...@gmail.com>
To: Ahmed Ashour <asas...@yahoo.com>
Cc: checkstyle <check...@googlegroups.com>
Sent: Thursday, September 3, 2015 9:36 PM
Subject: Re: StringIndexOutOfBoundsException

Roman Ivanov

unread,
Sep 4, 2015, 11:38:07 AM9/4/15
to Ahmed Ashour, checkstyle
Hi Ahmed,

I have to argue this is not the case here:

checkstyle should be convenient for users :) 


thanks,
Roman Ivanov
Reply all
Reply to author
Forward
0 new messages