From e04106bfdec398e1894410733968ec68b102d1d6 Mon Sep 17 00:00:00 2001 From: Alexey Ermakov Date: Fri, 8 Apr 2016 13:07:54 +0300 Subject: Set an explicit HTTP request timeout --- .../bitbucketpullrequestbuilder/bitbucket/ApiClient.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java index c8dfeb2..f5ccf9b 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java @@ -5,6 +5,7 @@ import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.DeleteMethod; +import org.apache.commons.httpclient.params.HttpClientParams; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; @@ -42,10 +43,16 @@ public class ApiClient { public static final byte MAX_KEY_SIZE_BB_API = 40; public static class HttpClientFactory { - public static final HttpClientFactory INSTANCE = new HttpClientFactory(); + public static final HttpClientFactory INSTANCE = new HttpClientFactory(); + private static final int DEFAULT_TIMEOUT = 60000; public HttpClient getInstanceHttpClient() { HttpClient client = new HttpClient(); + + HttpClientParams params = client.getParams(); + params.setConnectionManagerTimeout(DEFAULT_TIMEOUT); + params.setSoTimeout(DEFAULT_TIMEOUT); + if (Jenkins.getInstance() == null) return client; ProxyConfiguration proxy = Jenkins.getInstance().proxy; -- cgit v1.2.3