Skip to content

Commit

Permalink
Remove HttpConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Mar 21, 2024
1 parent 906a946 commit ca93db6
Show file tree
Hide file tree
Showing 30 changed files with 203 additions and 1,466 deletions.
1 change: 0 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
</limits>
<excludes>
<!-- V2.x changes -->
<exclude>org.kohsuke.github.connector.GitHubConnectorResponseHttpUrlConnectionAdapter</exclude>
<exclude>org.kohsuke.github.GHRepositorySearchBuilder.Fork</exclude>

<!-- Deprecated -->
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/kohsuke/github/GHAppInstallation.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ public Date getSuspendedAt() {
return GitHubClient.parseDate(suspendedAt);
}

/**
* Gets suspended by.
*
* @return the suspended by
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHUser getSuspendedBy() {
return suspendedBy;
}

/**
* Delete a Github App installation
* <p>
Expand Down
61 changes: 24 additions & 37 deletions src/main/java/org/kohsuke/github/GitHubBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.kohsuke.github.authorization.ImmutableAuthorizationProvider;
import org.kohsuke.github.connector.GitHubConnector;
import org.kohsuke.github.connector.GitHubConnectorResponse;
import org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -106,7 +105,7 @@ private static void loadIfSet(String envName, Properties p, String propName) {
* <p>
* See class javadoc for the relationship between these coordinates.
*
* @return the git hub builder
* @return the GitHubBuilder
* @throws IOException
* the io exception
*/
Expand All @@ -122,9 +121,9 @@ public static GitHubBuilder fromEnvironment() throws IOException {
}

/**
* From property file git hub builder.
* From property file GitHubBuilder.
*
* @return the git hub builder
* @return the GitHubBuilder
* @throws IOException
* the io exception
*/
Expand All @@ -135,11 +134,11 @@ public static GitHubBuilder fromPropertyFile() throws IOException {
}

/**
* From property file git hub builder.
* From property file GitHubBuilder.
*
* @param propertyFileName
* the property file name
* @return the git hub builder
* @return the GitHubBuilder
* @throws IOException
* the io exception
*/
Expand All @@ -157,11 +156,11 @@ public static GitHubBuilder fromPropertyFile(String propertyFileName) throws IOE
}

/**
* From properties git hub builder.
* From properties GitHubBuilder.
*
* @param props
* the props
* @return the git hub builder
* @return the GitHubBuilder
*/
public static GitHubBuilder fromProperties(Properties props) {
GitHubBuilder self = new GitHubBuilder();
Expand All @@ -180,39 +179,39 @@ public static GitHubBuilder fromProperties(Properties props) {
}

/**
* With endpoint git hub builder.
* With endpoint GitHubBuilder.
*
* @param endpoint
* The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or
* "https://ghe.acme.com/api/v3". Note that GitHub Enterprise has <code>/api/v3</code> in the URL. For
* historical reasons, this parameter still accepts the bare domain name, but that's considered
* deprecated.
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withEndpoint(String endpoint) {
this.endpoint = endpoint;
return this;
}

/**
* With o auth token git hub builder.
* With o auth token GitHubBuilder.
*
* @param oauthToken
* the oauth token
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withOAuthToken(String oauthToken) {
return withAuthorizationProvider(ImmutableAuthorizationProvider.fromOauthToken(oauthToken));
}

/**
* With o auth token git hub builder.
* With o auth token GitHubBuilder.
*
* @param oauthToken
* the oauth token
* @param user
* the user
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withOAuthToken(String oauthToken, String user) {
return withAuthorizationProvider(ImmutableAuthorizationProvider.fromOauthToken(oauthToken, user));
Expand All @@ -225,7 +224,7 @@ public GitHubBuilder withOAuthToken(String oauthToken, String user) {
*
* @param authorizationProvider
* the authorization provider
* @return the git hub builder
* @return the GitHubBuilder
*
*/
public GitHubBuilder withAuthorizationProvider(final AuthorizationProvider authorizationProvider) {
Expand All @@ -246,34 +245,22 @@ public GitHubBuilder withAppInstallationToken(String appInstallationToken) {
}

/**
* With jwt token git hub builder.
* With jwt token GitHubBuilder.
*
* @param jwtToken
* the jwt token
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withJwtToken(String jwtToken) {
return withAuthorizationProvider(ImmutableAuthorizationProvider.fromJwtToken(jwtToken));
}

/**
* With connector git hub builder.
* With connector GitHubBuilder.
*
* @param connector
* the connector
* @return the git hub builder
*/
@Deprecated
public GitHubBuilder withConnector(@Nonnull HttpConnector connector) {
return withConnector(GitHubConnectorHttpConnectorAdapter.adapt(connector));
}

/**
* With connector git hub builder.
*
* @param connector
* the connector
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withConnector(GitHubConnector connector) {
this.connector = connector;
Expand All @@ -299,7 +286,7 @@ public GitHubBuilder withConnector(GitHubConnector connector) {
*
* @param handler
* the handler
* @return the git hub builder
* @return the GitHubBuilder
* @see #withRateLimitChecker(RateLimitChecker)
*/
public GitHubBuilder withRateLimitHandler(GitHubRateLimitHandler handler) {
Expand All @@ -317,7 +304,7 @@ public GitHubBuilder withRateLimitHandler(GitHubRateLimitHandler handler) {
*
* @param handler
* the handler
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withAbuseLimitHandler(GitHubAbuseLimitHandler handler) {
this.abuseLimitHandler = handler;
Expand All @@ -329,7 +316,7 @@ public GitHubBuilder withAbuseLimitHandler(GitHubAbuseLimitHandler handler) {
*
* @param coreRateLimitChecker
* the {@link RateLimitChecker} for core GitHub API requests
* @return the git hub builder
* @return the GitHubBuilder
* @see #withRateLimitChecker(RateLimitChecker, RateLimitTarget)
*/
public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker coreRateLimitChecker) {
Expand Down Expand Up @@ -358,7 +345,7 @@ public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker coreRateLimi
* the {@link RateLimitChecker} for requests
* @param rateLimitTarget
* the {@link RateLimitTarget} specifying which rate limit record to check
* @return the git hub builder
* @return the GitHubBuilder
*/
public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker rateLimitChecker,
@Nonnull RateLimitTarget rateLimitTarget) {
Expand All @@ -369,7 +356,7 @@ public GitHubBuilder withRateLimitChecker(@Nonnull RateLimitChecker rateLimitChe
/**
* Builds a {@link GitHub} instance.
*
* @return the git hub
* @return the github
* @throws IOException
* the io exception
*/
Expand All @@ -385,7 +372,7 @@ public GitHub build() throws IOException {
/**
* Clone.
*
* @return the git hub builder
* @return the GitHubBuilder
*/
@Override
public GitHubBuilder clone() {
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/org/kohsuke/github/GitHubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,6 @@ public boolean isOffline() {
return connector == GitHubConnector.OFFLINE;
}

/**
* Gets connector.
*
* @return the connector
*/
@Deprecated
public HttpConnector getConnector() {
if (!(connector instanceof HttpConnector)) {
throw new UnsupportedOperationException("This GitHubConnector does not support HttpConnector.connect().");
}

LOGGER.warning(
"HttpConnector and getConnector() are deprecated. Please file an issue describing your use case.");
return (HttpConnector) connector;
}

/**
* Is this an anonymous connection.
*
Expand Down
44 changes: 0 additions & 44 deletions src/main/java/org/kohsuke/github/HttpConnector.java

This file was deleted.

13 changes: 7 additions & 6 deletions src/main/java/org/kohsuke/github/connector/GitHubConnector.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.kohsuke.github.connector;

import org.kohsuke.github.HttpConnector;
import org.kohsuke.github.GHIOException;
import org.kohsuke.github.internal.DefaultGitHubConnector;
import org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter;

import java.io.IOException;

Expand Down Expand Up @@ -47,9 +46,11 @@ public interface GitHubConnector {

/**
* Stub implementation that is always off-line.
*
* This connector currently uses {@link GitHubConnectorHttpConnectorAdapter} to maintain backward compatibility as
* much as possible.
*/
GitHubConnector OFFLINE = new GitHubConnectorHttpConnectorAdapter(HttpConnector.OFFLINE);
GitHubConnector OFFLINE = new GitHubConnector() {
@Override
public GitHubConnectorResponse send(GitHubConnectorRequest connectorRequest) throws IOException {
throw new GHIOException("Offline");
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.*;
import java.util.zip.GZIPInputStream;

Expand Down Expand Up @@ -61,20 +60,6 @@ protected GitHubConnectorResponse(@Nonnull GitHubConnectorRequest request,
this.headers = Collections.unmodifiableMap(caseInsensitiveMap);
}

/**
* Get this response as a {@link HttpURLConnection}.
*
* @return an object that implements at least the response related methods of {@link HttpURLConnection}.
* @deprecated This method is present only to provide backward compatibility with other deprecated components.
*/
@Deprecated
@Nonnull
public HttpURLConnection toHttpURLConnection() {
HttpURLConnection connection;
connection = new GitHubConnectorResponseHttpUrlConnectionAdapter(this);
return connection;
}

/**
* Gets the value of a header field for this response.
*
Expand Down
Loading

0 comments on commit ca93db6

Please sign in to comment.