diff options
author | Alexey Ermakov <zee@technocore.ru> | 2016-04-08 13:07:54 +0300 |
---|---|---|
committer | Alexey Ermakov <zee@technocore.ru> | 2016-04-08 13:07:54 +0300 |
commit | e04106bfdec398e1894410733968ec68b102d1d6 (patch) | |
tree | fac87700cda629e53bb610338ee9668797c2f330 /src/main/java/bitbucketpullrequestbuilder | |
parent | f08fe64257973cddea7ca3ae837f5cfe3db7b720 (diff) | |
download | bbprb-e04106bfdec398e1894410733968ec68b102d1d6.tar.gz |
Set an explicit HTTP request timeout
Diffstat (limited to 'src/main/java/bitbucketpullrequestbuilder')
-rw-r--r-- | src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java | 9 |
1 files changed, 8 insertions, 1 deletions
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; |