Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from Commons HttpClient 3.x to HttpComponents Client 4.x #49

Merged
merged 3 commits into from
Oct 29, 2022

Conversation

basil
Copy link
Member

@basil basil commented Oct 28, 2022

Problem

jdk-tool, which is bundled in core, uses a patched version of the deprecated Commons HttpClient 3.x library. Using deprecated code is not sustainable and inhibits us from eventually removing this library from core in jenkinsci/jenkins#7312.

Solution

While in the long term this plugin ought to be rewritten to comply with JDK Script Friendly URLs and/or the native HTTP client in newer versions of the Java Platform, both of those are more involved changes. In the short term the most expedient solution that allows this plugin to still be bundled with Jenkins core (but without using a deprecated library) is to upgrade from Commons HttpClient 3.x to HttpComponents Client 4.x.

Testing done

With

diff --git a/src/main/java/hudson/tools/JDKInstaller.java b/src/main/java/hudson/tools/JDKInstaller.java
index 07e2a3d..7abbf15 100644
--- a/src/main/java/hudson/tools/JDKInstaller.java
+++ b/src/main/java/hudson/tools/JDKInstaller.java
@@ -480,7 +480,7 @@ public class JDKInstaller extends ToolInstaller {
 
         int authCount=0, totalPageCount=0;  // counters for avoiding infinite loop
 
-        HttpRequestBase m = new HttpGet(primary.filepath);
+        HttpRequestBase m = new HttpGet("https://download.oracle.com/java/17/archive/jdk-17_linux-x64_bin.tar.gz");
 
         BasicClientCookie cookie = new BasicClientCookie("gpw_e24", ".");
         cookie.setDomain(".oracle.com");

I exercised all the changed lines (including proxy authentication) in a Pipeline job in the debugger except for the if (m.getURI().getHost().equals("login.oracle.com")) code path (lines 516-579) which I could not test because I do not have an Oracle support contract. I doubt that code path still works anyway. If it actually was working before and happens to regress, and if some user with an Oracle support contract actually cares about this, I would encourage them to debug it using their Oracle account and submit a pull request.

CC @jglick

…d: Plugin:jdk-tool -> Plugin:apache-httpcomponents-client-4-api -> Plugin:command-launcher -> Plugin:jdk-tool

        at hudson.PluginManager$1$3$2$1.reactOnCycle(PluginManager.java:485)
        at hudson.PluginManager$1$3$2$1.reactOnCycle(PluginManager.java:462)
        at hudson.util.CyclicGraphDetector.detectedCycle(CyclicGraphDetector.java:63)
        at hudson.util.CyclicGraphDetector.visit(CyclicGraphDetector.java:52)
        at hudson.util.CyclicGraphDetector.visit(CyclicGraphDetector.java:53)
        at hudson.util.CyclicGraphDetector.visit(CyclicGraphDetector.java:53)
        at hudson.util.CyclicGraphDetector.run(CyclicGraphDetector.java:24)
        at hudson.PluginManager$1$3$2.run(PluginManager.java:490)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1151)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        ... 1 more
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. Do we still somehow advertise even the existence of this plugin somehow?

@basil
Copy link
Member Author

basil commented Oct 29, 2022

Not that I know of, but there are a large number of existing installations (hopefully unused!).

@jglick jglick added the enhancement New feature or request label Oct 29, 2022
@jglick jglick merged commit f33aa27 into jenkinsci:master Oct 29, 2022
basil added a commit to basil/jenkins that referenced this pull request Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants