Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4065

Maven Release plugin throws exception and fails silently



    • Bug
    • Resolution: Fixed
    • Major
    • m2release-plugin
    • None
    • Platform: All, OS: All


      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
      at sun.reflect.GeneratedMethodAccessor886.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)
      at org.apache.commons.jexl.parser.ASTReference.execute
      at org.apache.commons.jexl.parser.ASTReference.value
      at org.apache.commons.jexl.parser.ASTReferenceExpression.value

      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

      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 }




            Unassigned Unassigned
            dmclaren dmclaren
            0 Vote for this issue
            0 Start watching this issue