aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorS.Nishio <nishio@densan-labs.net>2016-12-10 18:02:35 +0900
committerGitHub <noreply@github.com>2016-12-10 18:02:35 +0900
commitfa120fa3e9cfd437594306c500270bc9bbf601a2 (patch)
tree23dd7fda1a83b3284d8f423aaa56821cb8845aee /src/main/java
parent794672fa177dcb95c1b55746d5df63623fccc8c1 (diff)
parente04106bfdec398e1894410733968ec68b102d1d6 (diff)
downloadbbprb-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.java9
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;