From f071bc291c0067c44095380a6fd66f8e7f4917fb Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 6 Jan 2025 12:41:24 -0800 Subject: [PATCH 1/4] Remove Commons Discovery --- bom/pom.xml | 3 ++- core/src/main/java/hudson/cli/CLICommand.java | 19 ------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index 8de2f4bc33ad..2cff9eec1526 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -39,7 +39,8 @@ THE SOFTWARE. 2.0.0-M2 - 1928.v9115fe47607f + + 1939.v0750b_2e6f5b_d 2.4.21 diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index ba7fd4250fdd..8b17377445bc 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -53,11 +53,6 @@ import java.util.logging.Logger; import jenkins.model.Jenkins; import jenkins.util.SystemProperties; -import org.apache.commons.discovery.ResourceClassIterator; -import org.apache.commons.discovery.ResourceNameIterator; -import org.apache.commons.discovery.resource.ClassLoaders; -import org.apache.commons.discovery.resource.classes.DiscoverClasses; -import org.apache.commons.discovery.resource.names.DiscoverServiceNames; import org.jvnet.hudson.annotation_indexer.Index; import org.jvnet.tiger_types.Types; import org.kohsuke.accmod.Restricted; @@ -573,20 +568,6 @@ public static CLICommand getCurrent() { } catch (IOException e) { throw new UncheckedIOException(e); } - - // Register OptionHandlers through META-INF/services and Commons Discovery - ClassLoaders cls = new ClassLoaders(); - cls.put(j.getPluginManager().uberClassLoader); - ResourceNameIterator servicesIter = - new DiscoverServiceNames(cls).findResourceNames(OptionHandler.class.getName()); - final ResourceClassIterator itr = - new DiscoverClasses(cls).findResourceClasses(servicesIter); - - while (itr.hasNext()) { - Class h = itr.nextResourceClass().loadClass(); - Class c = Types.erasure(Types.getTypeArgument(Types.getBaseClass(h, OptionHandler.class), 0)); - CmdLineParser.registerHandler(c, h); - } } } From 2e52635b43735b1b7fc13f7f4dfd093a40d39e26 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 6 Jan 2025 13:01:21 -0800 Subject: [PATCH 2/4] Use existing local variable --- core/src/main/java/hudson/cli/CLICommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index 8b17377445bc..eefaf90c9ecc 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -561,7 +561,7 @@ public static CLICommand getCurrent() { if (j != null) { // only when running on the controller // Register OptionHandlers through META-INF/services/annotations and Annotation Indexer try { - for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.get().pluginManager.uberClassLoader, Class.class)) { + for (Class c : Index.list(OptionHandlerExtension.class, j.getPluginManager().uberClassLoader, Class.class)) { Type t = Types.getBaseClass(c, OptionHandler.class); CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t, 0)), c); } From 966b7fabd5b09a6d4fbaba82c4ee765a879dd81c Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 6 Jan 2025 14:30:55 -0800 Subject: [PATCH 3/4] https://github.com/jenkinsci/jenkins/pull/10122#issuecomment-2574018428 --- .../main/java/hudson/cli/handlers/GenericItemOptionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java b/core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java index 99bae388ca68..6941334f5be2 100644 --- a/core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java +++ b/core/src/main/java/hudson/cli/handlers/GenericItemOptionHandler.java @@ -42,7 +42,7 @@ /** * Refers to an {@link Item} by its name. * May be subclassed to handle specific kinds of items. - * (Use {@code @MetaInfServices(OptionHandler.class)} to register the subclass.) + * (Use {@code @OptionHandlerExtension} to register the subclass.) * @param the kind of item being handled * @since 1.538 */ From 6f5f489c40df653585cb7dee071af18461d8f130 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 8 Jan 2025 12:53:23 -0800 Subject: [PATCH 4/4] Released build --- bom/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index 1e4d1651f71e..be60327d403f 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -41,8 +41,7 @@ THE SOFTWARE. 2.0.0-M2 2.4.21 1.1-jenkins-20250108 - - 1941.va_0b_2934ecb_68 + 1942.v708e07325402