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

Do not cache the GitHub client #812

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbGitHubAuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ public class GhprbGitHubAuth extends AbstractDescribableImpl<GhprbGitHubAuth> {

private final Secret secret;

private transient GitHub gh;

@DataBoundConstructor
public GhprbGitHubAuth(
String serverAPIUrl,
Expand Down Expand Up @@ -200,27 +198,24 @@ private static GitHubBuilder getBuilder(Item context, String serverAPIUrl, Strin
return builder;
}

private void buildConnection(Item context) {
private GitHub buildConnection(Item context) {
GitHubBuilder builder = getBuilder(context, serverAPIUrl, credentialsId);
if (builder == null) {
LOGGER.log(Level.SEVERE, "Unable to get builder using credentials: {0}", credentialsId);
return;
return null;
}

try {
gh = builder.build();
return builder.build();
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Unable to connect using credentials: " + credentialsId, e);
}

return null;
}

public GitHub getConnection(Item context) throws IOException {
synchronized (this) {
if (gh == null) {
buildConnection(context);
}

return gh;
}
return buildConnection(context);
}

@Override
Expand Down