Skip to content

Commit 8591472

Browse files
authored
Merge pull request #705 from Dohbedoh/JENKINS-70163
[JENKINS-70163] Do not cache resolved proxy address in Connector clients
2 parents d391eef + e481617 commit 8591472

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
<dependency>
6868
<groupId>io.jenkins.plugins</groupId>
6969
<artifactId>okhttp-api</artifactId>
70+
<!--Remove once this version is in the bom-->
71+
<version>4.10.0-136.v1d8ce1b_1db_72</version>
7072
</dependency>
7173
<dependency>
7274
<groupId>org.jenkins-ci.plugins</groupId>

src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
import java.io.File;
5555
import java.io.IOException;
5656
import java.net.HttpURLConnection;
57-
import java.net.MalformedURLException;
58-
import java.net.Proxy;
59-
import java.net.URL;
6057
import java.nio.charset.StandardCharsets;
6158
import java.security.MessageDigest;
6259
import java.security.NoSuchAlgorithmException;
@@ -75,7 +72,6 @@
7572
import java.util.logging.Logger;
7673
import jenkins.model.Jenkins;
7774
import jenkins.scm.api.SCMSourceOwner;
78-
import jenkins.util.JenkinsJVM;
7975
import jenkins.util.SystemProperties;
8076
import okhttp3.Cache;
8177
import okhttp3.OkHttpClient;
@@ -445,22 +441,12 @@ static GitHubBuilder createGitHubBuilder(@NonNull String apiUrl) throws IOExcept
445441
@NonNull
446442
private static GitHubBuilder createGitHubBuilder(@NonNull String apiUrl, @CheckForNull Cache cache)
447443
throws IOException {
448-
String host;
449-
try {
450-
host = new URL(apiUrl).getHost();
451-
} catch (MalformedURLException e) {
452-
throw new IOException("Invalid GitHub API URL: " + apiUrl, e);
453-
}
454-
455444
GitHubBuilder gb = new GitHubBuilder();
456445
gb.withEndpoint(apiUrl);
457446
gb.withRateLimitChecker(new ApiRateLimitChecker.RateLimitCheckerAdapter());
458447
gb.withRateLimitHandler(CUSTOMIZED);
459448

460449
OkHttpClient.Builder clientBuilder = baseClient.newBuilder();
461-
if (JenkinsJVM.isJenkinsJVM()) {
462-
clientBuilder.proxy(getProxy(host));
463-
}
464450
if (cache != null) {
465451
clientBuilder.cache(cache);
466452
}
@@ -530,22 +516,6 @@ static List<DomainRequirement> githubDomainRequirements(String apiUri) {
530516
.build();
531517
}
532518

533-
/**
534-
* Uses proxy if configured on pluginManager/advanced page
535-
*
536-
* @param host GitHub's hostname to build proxy to
537-
* @return proxy to use it in connector. Should not be null as it can lead to unexpected behaviour
538-
*/
539-
@NonNull
540-
private static Proxy getProxy(@NonNull String host) {
541-
Jenkins jenkins = Jenkins.getInstanceOrNull();
542-
if (jenkins == null || jenkins.proxy == null) {
543-
return Proxy.NO_PROXY;
544-
} else {
545-
return jenkins.proxy.createProxy(host);
546-
}
547-
}
548-
549519
/** Fail immediately and throw a customized exception. */
550520
public static final RateLimitHandler CUSTOMIZED = new RateLimitHandler() {
551521

0 commit comments

Comments
 (0)