java.lang.StringIndexOutOfBoundsException

If you like a tip written by other Samebug users, mark is as helpful! Marks help our algorithm provide you better solutions and also help other users.
tip

You need to make sure that capitalisation of the case for the plugin in the
properties file is exactly: "AllocinePlugin" and not "allocineplugin"

tip

This is a bug when using Micromax devices with VideoView. You can either exclude these devices or look at this workaround: http://stackoverflow.com/a/31942841/4347859

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • I am trying to use the M2Release plugin, but have encountered a problem which appears to be related to the format of my version strings which are of the form n-SNAPSHOT which result in a release number of 'n'. When I 'Perform Maven Release' I get as far as pushing the 'Schedule Maven Release Build' button after which nothing much happens. In the log I get the following exception: ================================================================================ ====================== 20-Jul-2009 11:10:48 hudson.ExpressionFactory2$JexlExpression evaluate WARNING: Caught exception evaluating: it.computeNextVersion(m.version). Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.computeNextVersion (M2ReleaseAction.java:100) at sun.reflect.GeneratedMethodAccessor886.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke (UberspectImpl.java:258) at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104) at org.apache.commons.jexl.parser.ASTReference.execute (ASTReference.java:83) at org.apache.commons.jexl.parser.ASTReference.value (ASTReference.java:57) at org.apache.commons.jexl.parser.ASTReferenceExpression.value (ASTReferenceExpression.java:51) ================================================================================ ====================== I believe that line 100 in the following extract from the code from M2ReleaseAction.java is the point of failure, and is actually redundant. If I read this correctly then with a release version of the form 'n' the 'lastIndexOf' at line 88 will return -1. This will result in the 'else; path being taken and at line 100 substring will be called with the parameters 0 and -1 which throws the exception. Even if it did not thrown and exception the retVal returned from the the substring is ignored. I believe that the removal of line 100 would resolve the problem. 84 public String computeNextVersion(String version) { 85 /// XXX would be nice to use maven to do this... 86 String retVal = computeReleaseVersion(version); 87 // get the integer after the last "." 88 int dotIdx = retVal.lastIndexOf('.'); 89 if (dotIdx != -1) { 90 dotIdx++; 91 String ver = retVal.substring(dotIdx); 92 int intVer = Integer.parseInt(ver); 93 intVer += 1; 94 retVal = retVal.substring(0, dotIdx); 95 retVal = retVal + intVer; 96 } 97 else { 98 int intVer = Integer.parseInt(retVal); 99 intVer += 1; 100 retVal = retVal.substring(0, dotIdx); 101 retVal = Integer.toString(intVer); 102 } 103 return retVal + "-SNAPSHOT"; //$NON-NLS-1$ 104 }
    via by dmclaren,
  • I am trying to use the M2Release plugin, but have encountered a problem which appears to be related to the format of my version strings which are of the form n-SNAPSHOT which result in a release number of 'n'. When I 'Perform Maven Release' I get as far as pushing the 'Schedule Maven Release Build' button after which nothing much happens. In the log I get the following exception: ================================================================================ ====================== 20-Jul-2009 11:10:48 hudson.ExpressionFactory2$JexlExpression evaluate WARNING: Caught exception evaluating: it.computeNextVersion(m.version). Reason: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.computeNextVersion (M2ReleaseAction.java:100) at sun.reflect.GeneratedMethodAccessor886.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke (UberspectImpl.java:258) at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104) at org.apache.commons.jexl.parser.ASTReference.execute (ASTReference.java:83) at org.apache.commons.jexl.parser.ASTReference.value (ASTReference.java:57) at org.apache.commons.jexl.parser.ASTReferenceExpression.value (ASTReferenceExpression.java:51) ================================================================================ ====================== I believe that line 100 in the following extract from the code from M2ReleaseAction.java is the point of failure, and is actually redundant. If I read this correctly then with a release version of the form 'n' the 'lastIndexOf' at line 88 will return -1. This will result in the 'else; path being taken and at line 100 substring will be called with the parameters 0 and -1 which throws the exception. Even if it did not thrown and exception the retVal returned from the the substring is ignored. I believe that the removal of line 100 would resolve the problem. 84 public String computeNextVersion(String version) { 85 /// XXX would be nice to use maven to do this... 86 String retVal = computeReleaseVersion(version); 87 // get the integer after the last "." 88 int dotIdx = retVal.lastIndexOf('.'); 89 if (dotIdx != -1) { 90 dotIdx++; 91 String ver = retVal.substring(dotIdx); 92 int intVer = Integer.parseInt(ver); 93 intVer += 1; 94 retVal = retVal.substring(0, dotIdx); 95 retVal = retVal + intVer; 96 } 97 else { 98 int intVer = Integer.parseInt(retVal); 99 intVer += 1; 100 retVal = retVal.substring(0, dotIdx); 101 retVal = Integer.toString(intVer); 102 } 103 return retVal + "-SNAPSHOT"; //$NON-NLS-1$ 104 }
    via by dmclaren,
  • ArrayOutofBound Exception not caught
    via Stack Overflow by Monojeet Nayak
    ,
  • RESTEasy / Mailing Lists
    via by Unknown author,
    • java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at org.jvnet.hudson.plugins.m2release.M2ReleaseAction.computeNextVersion(M2ReleaseAction.java:100) at sun.reflect.GeneratedMethodAccessor886.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585)

    Users with the same issue

    zsamboki
    1 times, last one,
    osvzs
    2 times, last one,
    richard77
    2 times, last one,
    MoYapro
    1 times, last one,
    kjhdofjosvs
    2 times, last one,
    92 more bugmates