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

Maven Release plugin throws exception and fails silently

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Component/s: m2release-plugin
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      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 }

        Attachments

          Activity

            People

            • Assignee:
              teilo James Nord
              Reporter:
              dmclaren dmclaren
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: