-
Bug
-
Resolution: Fixed
-
Major
-
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
(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)
97 else
103 return retVal + "-SNAPSHOT"; //$NON-NLS-1$
104 }
Code changed in hudson
User: : teilo
Path:
trunk/hudson/plugins/m2release/plugin/src/main/java/org/jvnet/hudson/plugins/m2release/M2ReleaseAction.java
http://fisheye4.cenqua.com/changelog/hudson/?cs=19962
Log:
[FIXED JENKINS-4065]
Removed the bogus line, and added some extra checks to prevent throwing exceptions if we don't even have a release number.