|
54 | 54 | import java.io.File; |
55 | 55 | import java.io.IOException; |
56 | 56 | import java.net.HttpURLConnection; |
57 | | -import java.net.MalformedURLException; |
58 | | -import java.net.Proxy; |
59 | | -import java.net.URL; |
60 | 57 | import java.nio.charset.StandardCharsets; |
61 | 58 | import java.security.MessageDigest; |
62 | 59 | import java.security.NoSuchAlgorithmException; |
|
75 | 72 | import java.util.logging.Logger; |
76 | 73 | import jenkins.model.Jenkins; |
77 | 74 | import jenkins.scm.api.SCMSourceOwner; |
78 | | -import jenkins.util.JenkinsJVM; |
79 | 75 | import jenkins.util.SystemProperties; |
80 | 76 | import okhttp3.Cache; |
81 | 77 | import okhttp3.OkHttpClient; |
@@ -445,22 +441,12 @@ static GitHubBuilder createGitHubBuilder(@NonNull String apiUrl) throws IOExcept |
445 | 441 | @NonNull |
446 | 442 | private static GitHubBuilder createGitHubBuilder(@NonNull String apiUrl, @CheckForNull Cache cache) |
447 | 443 | 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 | | - |
455 | 444 | GitHubBuilder gb = new GitHubBuilder(); |
456 | 445 | gb.withEndpoint(apiUrl); |
457 | 446 | gb.withRateLimitChecker(new ApiRateLimitChecker.RateLimitCheckerAdapter()); |
458 | 447 | gb.withRateLimitHandler(CUSTOMIZED); |
459 | 448 |
|
460 | 449 | OkHttpClient.Builder clientBuilder = baseClient.newBuilder(); |
461 | | - if (JenkinsJVM.isJenkinsJVM()) { |
462 | | - clientBuilder.proxy(getProxy(host)); |
463 | | - } |
464 | 450 | if (cache != null) { |
465 | 451 | clientBuilder.cache(cache); |
466 | 452 | } |
@@ -530,22 +516,6 @@ static List<DomainRequirement> githubDomainRequirements(String apiUri) { |
530 | 516 | .build(); |
531 | 517 | } |
532 | 518 |
|
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 | | - |
549 | 519 | /** Fail immediately and throw a customized exception. */ |
550 | 520 | public static final RateLimitHandler CUSTOMIZED = new RateLimitHandler() { |
551 | 521 |
|
|
0 commit comments