You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "richard (JIRA)" <ji...@apache.org> on 2018/01/03 14:53:00 UTC
[jira] [Commented] (MCHECKSTYLE-344)
StringIndexOutOfBoundsException in RuleUtil
[ https://issues.apache.org/jira/browse/MCHECKSTYLE-344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16309744#comment-16309744 ]
richard commented on MCHECKSTYLE-344:
-------------------------------------
We hit this as well in sevntu at https://travis-ci.org/sevntu-checkstyle/sevntu.checkstyle/jobs/324422086 .
{noformat}
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring (String.java:1967)
at org.apache.maven.plugin.checkstyle.RuleUtil.getCategory (RuleUtil.java:95)
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.countViolations (CheckstyleViolationCheckMojo.java:651)
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute (CheckstyleViolationCheckMojo.java:576)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)
{noformat}
This is the result of a change in the XML file in Checkstyle starting with version 8.2 at https://github.com/checkstyle/checkstyle/issues/4607 .
By giving a module a unique id, we changed the XML file to print the id as the source instead of the full class name. This is why maven plugin is expecting a period in the source.
> StringIndexOutOfBoundsException in RuleUtil
> -------------------------------------------
>
> Key: MCHECKSTYLE-344
> URL: https://issues.apache.org/jira/browse/MCHECKSTYLE-344
> Project: Maven Checkstyle Plugin
> Issue Type: Bug
> Components: checkstyle:check
> Affects Versions: 2.17
> Reporter: fdvxxii
>
> {{RuleUtil}} has a bug at line 95:
> {code}
> final int end = eventSrcName.lastIndexOf('.');
> eventSrcName = eventSrcName.substring(0, end);
> {code}
> This code leads to a StringIndexOutOfBoundsException if the variable does not contain a period. I don't know if its a convention to have a period in that string, but either way the error message should me more expressive.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)