diff options
author | S.Nishio <nishio@densan-labs.net> | 2016-12-10 18:02:35 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-10 18:02:35 +0900 |
commit | fa120fa3e9cfd437594306c500270bc9bbf601a2 (patch) | |
tree | 23dd7fda1a83b3284d8f423aaa56821cb8845aee /src/main/java | |
parent | 794672fa177dcb95c1b55746d5df63623fccc8c1 (diff) | |
parent | e04106bfdec398e1894410733968ec68b102d1d6 (diff) | |
download | bbprb-fa120fa3e9cfd437594306c500270bc9bbf601a2.tar.gz |
Merge pull request #5 from technocoreai/http-client-timeout
Set an explicit HTTP request timeout
Diffstat (limited to 'src/main/java')
-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; |