Skip to content

Commit

Permalink
Change the configured http client provider in scribejava from Apache …
Browse files Browse the repository at this point in the history
…HTTP Client to JDK HTTP Client, as in the previous implementation with the scribe library. There is no gain in using a client with a pooled connection manager that is destroyed every time a new token is requested.

This commit fix the ClassNotFoundException issue of org.apache.logging.log4j.spi.LoggerAdapter (commons-logging is marked as a scope dependency in the pom-plugin) when scm is used in a scripted pipeline.
  • Loading branch information
nfalco79 committed Nov 21, 2024
1 parent 3bf7402 commit 5f0ad1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-httpclient-apache</artifactId>
<artifactId>scribejava-core</artifactId>
<version>8.3.3</version>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.httpclient.jdk.JDKHttpClientConfig;
import com.github.scribejava.core.model.OAuth2AccessToken;
import com.github.scribejava.core.model.OAuthConstants;
import com.github.scribejava.core.oauth.OAuth20Service;
import com.github.scribejava.httpclient.apache.ApacheHttpClientConfig;
import hudson.model.Descriptor.FormException;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
Expand All @@ -31,11 +31,11 @@ public class BitbucketOAuthAuthenticator extends BitbucketAuthenticator {
public BitbucketOAuthAuthenticator(StandardUsernamePasswordCredentials credentials) throws AuthenticationTokenException {
super(credentials);

try (SetContextClassLoader cl = new SetContextClassLoader(this.getClass())) {
OAuth20Service service = new ServiceBuilder(credentials.getUsername())
.apiSecret(credentials.getPassword().getPlainText())
.httpClientConfig(ApacheHttpClientConfig.defaultConfig())
.build(BitbucketOAuth.instance());
try (SetContextClassLoader cl = new SetContextClassLoader(this.getClass());
OAuth20Service service = new ServiceBuilder(credentials.getUsername())
.apiSecret(credentials.getPassword().getPlainText())
.httpClientConfig(JDKHttpClientConfig.defaultConfig())
.build(BitbucketOAuth.instance())) {

Check warning on line 38 in src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/credentials/BitbucketOAuthAuthenticator.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 34-38 are not covered by tests
token = service.getAccessTokenClientCredentialsGrant();
} catch (IOException | InterruptedException | ExecutionException e) {
throw new AuthenticationTokenException(e);
Expand Down

0 comments on commit 5f0ad1f

Please sign in to comment.