Skip to content
Permalink
Browse files

[FIXED JENKINS-44557] Properly cast GString in vargs.

  • Loading branch information...
abayer committed Sep 18, 2017
1 parent 244f31e commit 8abef0d66fa78f4c187789d8fb76680b91ff0e97
@@ -37,6 +37,7 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.apache.commons.lang.ClassUtils;
import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;

/**
* Assists in determination of which method or other JVM element is actually about to be called by Groovy.
@@ -99,10 +100,7 @@ private static boolean matches(@Nonnull Class<?>[] parameterTypes, @Nonnull Obje
// not a varargs call
return parameters;
} else {
Object array = Array.newInstance(componentType, arrayLength);
for (int i = 0; i < arrayLength; i++) {
Array.set(array, i, parameters[fixedLen + i]);
}
Object array = DefaultTypeTransformation.castToVargsArray(parameters, 0, parameterTypes[fixedLen]);
Object[] parameters2 = new Object[fixedLen + 1];
System.arraycopy(parameters, 0, parameters2, 0, fixedLen);
parameters2[fixedLen] = array;
@@ -914,4 +914,14 @@ public void enumWithStringAndVarargs() throws Exception {
String expected = "The first thing";
assertEvaluate(new GenericWhitelist(), expected, script);
}

@Issue("JENKINS-44557")
@Test
public void varArgsWithGString() throws Exception {
ProxyWhitelist wl = new ProxyWhitelist(new GenericWhitelist(), new AnnotatedWhitelist());
String uv = UsesVarargs.class.getName();

assertEvaluate(wl, 3, "def twoStr = 'two'; " + uv + ".len('one', \"${twoStr}\", 'three')");

}
}

0 comments on commit 8abef0d

Please sign in to comment.
You can’t perform that action at this time.