From 149591e1b3c82ba5ed12d01ba4ebb24bc9d70ca4 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 9 Apr 2020 22:06:52 +0100 Subject: [PATCH] Remove commons-lang3 --- pom.xml | 5 ----- .../plugins/workflow/libs/LibraryStep.java | 18 +++++------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 79436de8..9dc5acf6 100644 --- a/pom.xml +++ b/pom.xml @@ -132,11 +132,6 @@ ivy 2.4.0 - - org.apache.commons - commons-lang3 - 3.7 - org.jenkins-ci.plugins.workflow workflow-support diff --git a/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java b/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java index 4ff7faa2..cad49424 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java @@ -41,7 +41,6 @@ import java.io.File; import java.io.IOException; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URI; @@ -60,9 +59,8 @@ import javax.annotation.Nonnull; import javax.inject.Inject; import jenkins.model.Jenkins; -import org.apache.commons.lang3.reflect.ConstructorUtils; -import org.apache.commons.lang3.reflect.MethodUtils; import org.codehaus.groovy.control.MultipleCompilationErrorsException; +import org.codehaus.groovy.runtime.InvokerHelper; import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.AbstractWhitelist; import org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException; import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution; @@ -265,16 +263,10 @@ public static final class LoadedClasses extends GroovyObjectSupport implements S @Override public Object invokeMethod(String name, Object _args) { Class c = loadClass(prefix + clazz); Object[] args = _args instanceof Object[] ? (Object[]) _args : new Object[] {_args}; // TODO why does Groovy not just pass an Object[] to begin with?! - try { - if (name.equals("new")) { - return ConstructorUtils.invokeConstructor(c, args); - } else { - return MethodUtils.invokeStaticMethod(c, name, args); - } - } catch (InvocationTargetException x) { - throw new GroovyRuntimeException(x.getCause()); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException x) { - throw new GroovyRuntimeException(x); + if (name.equals("new")) { + return InvokerHelper.invokeConstructorOf(c, args); + } else { + return InvokerHelper.invokeStaticMethod(c, name, args); } }