From 6343973db970da7a0e46cc95ed98f4f0205f81e0 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Sun, 21 Nov 2021 00:06:47 -0800 Subject: [PATCH] Make HttpClientGitHubConnector the default for Java 11+ --- src/main/java/org/kohsuke/github/GitHubClient.java | 2 +- .../github/internal/DefaultGitHubConnector.java | 10 +++++----- .../java/org/kohsuke/github/RequesterRetryTest.java | 2 +- .../github/internal/DefaultGitHubConnectorTest.java | 2 -- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GitHubClient.java b/src/main/java/org/kohsuke/github/GitHubClient.java index e77f0389b2..a5db6d4ac7 100644 --- a/src/main/java/org/kohsuke/github/GitHubClient.java +++ b/src/main/java/org/kohsuke/github/GitHubClient.java @@ -391,7 +391,7 @@ public GitHubResponse sendRequest(GitHubRequest request, @CheckForNull Bo connectorRequest = e.connectorRequest; } } catch (SocketException | SocketTimeoutException | SSLHandshakeException e) { - // These transient errors the + // These transient errors thrown by HttpURLConnection if (retries > 0) { logRetryConnectionError(e, request.url(), retries); continue; diff --git a/src/main/java/org/kohsuke/github/internal/DefaultGitHubConnector.java b/src/main/java/org/kohsuke/github/internal/DefaultGitHubConnector.java index 1f7d488036..1b00b01596 100644 --- a/src/main/java/org/kohsuke/github/internal/DefaultGitHubConnector.java +++ b/src/main/java/org/kohsuke/github/internal/DefaultGitHubConnector.java @@ -50,11 +50,11 @@ static GitHubConnector create(String defaultConnectorProperty) { } else if (defaultConnectorProperty.equalsIgnoreCase("httpclient")) { return new HttpClientGitHubConnector(); } else if (defaultConnectorProperty.equalsIgnoreCase("default")) { - // try { - // return new HttpClientGitHubConnector(); - // } catch (UnsupportedOperationException | LinkageError e) { - return new GitHubConnectorHttpConnectorAdapter(HttpConnector.DEFAULT); - // } + try { + return new HttpClientGitHubConnector(); + } catch (UnsupportedOperationException | LinkageError e) { + return new GitHubConnectorHttpConnectorAdapter(HttpConnector.DEFAULT); + } } else { throw new IllegalStateException( "Property 'test.github.connector' must reference a valid built-in connector - okhttp, okhttpconnector, urlconnection, or default."); diff --git a/src/test/java/org/kohsuke/github/RequesterRetryTest.java b/src/test/java/org/kohsuke/github/RequesterRetryTest.java index 9e1cc76164..5981a30ca5 100644 --- a/src/test/java/org/kohsuke/github/RequesterRetryTest.java +++ b/src/test/java/org/kohsuke/github/RequesterRetryTest.java @@ -78,7 +78,7 @@ public void resetTestCapturedLog() throws IOException { attachLogCapturer(); } - @Ignore("Used okhttp3 and this to verify connection closing. To variable for CI system.") + @Ignore("Used okhttp3 and this to verify connection closing. Too flaky for CI system.") @Test public void testGitHubIsApiUrlValid() throws Exception { diff --git a/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java b/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java index 7469f64069..e7f66b1ff1 100644 --- a/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java +++ b/src/test/java/org/kohsuke/github/internal/DefaultGitHubConnectorTest.java @@ -37,8 +37,6 @@ public void testCreate() throws Exception { connector = DefaultGitHubConnector.create("default"); - // Current implementation never uses httpclient for default. - usingHttpClient = false; if (usingHttpClient) { assertThat(connector, instanceOf(HttpClientGitHubConnector.class)); } else {