Skip to content

Commit

Permalink
Merge pull request #207 from dpursehouse/deprecated-http-client
Browse files Browse the repository at this point in the history
Don't use deprecated DefaultHttpClient
  • Loading branch information
rsandell committed Apr 8, 2015
2 parents ca3b4d2 + 50ed353 commit 5fd07b8
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -75,8 +75,11 @@
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClients;
import org.jvnet.localizer.ResourceBundleHolder;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
Expand Down Expand Up @@ -718,11 +721,14 @@ public FormValidation doTestRestConnection(
if (gerritFrontEndUrl != null && !gerritFrontEndUrl.endsWith("/")) {
restUrl = gerritFrontEndUrl + "/";
}
DefaultHttpClient httpclient = new DefaultHttpClient();
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(null, -1),
new UsernamePasswordCredentials(gerritHttpUserName,
gerritHttpPassword));
HttpClient httpclient = HttpClients.custom()
.setDefaultCredentialsProvider(credsProvider)
.build();
HttpGet httpGet = new HttpGet(restUrl + "a/projects/?d");
httpclient.getCredentialsProvider().setCredentials(new AuthScope(null, -1),
new UsernamePasswordCredentials(gerritHttpUserName,
gerritHttpPassword));
HttpResponse execute;
try {
execute = httpclient.execute(httpGet);
Expand Down

0 comments on commit 5fd07b8

Please sign in to comment.