From 4464b60d2135030492c2b472fe275b6ecc784c90 Mon Sep 17 00:00:00 2001 From: David Sitte Date: Tue, 11 Nov 2014 09:53:33 -0800 Subject: [PATCH 1/2] Add a 10 second HTTPClient connection timeout --- .../jenkins/plugins/hipchat/StandardHipChatService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java b/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java index cfb850f..8f4035b 100644 --- a/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java +++ b/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java @@ -11,6 +11,10 @@ public class StandardHipChatService implements HipChatService { + /** + * HTTP Connection timeout when making calls to HipChat + */ + public static final Integer CONNECTION_TIMEOUT = 10000; private static final Logger logger = Logger.getLogger(StandardHipChatService.class.getName()); private static final String[] DEFAULT_ROOMS = new String[0]; @@ -60,6 +64,8 @@ public void publish(String message, String color) { private HttpClient getHttpClient() { HttpClient client = new HttpClient(); + client.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECTION_TIMEOUT); + client.getHttpConnectionManager().getParams().setSoTimeout(CONNECTION_TIMEOUT); if (Jenkins.getInstance() != null) { ProxyConfiguration proxy = Jenkins.getInstance().proxy; From b59fd12709adff298b31c3e97fd9a8b4099b782f Mon Sep 17 00:00:00 2001 From: David Sitte Date: Wed, 12 Nov 2014 11:56:13 -0800 Subject: [PATCH 2/2] Rename to DEFAULT_TIMEOUT It is being used for both connection and read timeout. --- .../jenkins/plugins/hipchat/StandardHipChatService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java b/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java index 8f4035b..f5fe675 100644 --- a/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java +++ b/src/main/java/jenkins/plugins/hipchat/StandardHipChatService.java @@ -14,7 +14,7 @@ public class StandardHipChatService implements HipChatService { /** * HTTP Connection timeout when making calls to HipChat */ - public static final Integer CONNECTION_TIMEOUT = 10000; + public static final Integer DEFAULT_TIMEOUT = 10000; private static final Logger logger = Logger.getLogger(StandardHipChatService.class.getName()); private static final String[] DEFAULT_ROOMS = new String[0]; @@ -64,8 +64,8 @@ public void publish(String message, String color) { private HttpClient getHttpClient() { HttpClient client = new HttpClient(); - client.getHttpConnectionManager().getParams().setConnectionTimeout(CONNECTION_TIMEOUT); - client.getHttpConnectionManager().getParams().setSoTimeout(CONNECTION_TIMEOUT); + client.getHttpConnectionManager().getParams().setConnectionTimeout(DEFAULT_TIMEOUT); + client.getHttpConnectionManager().getParams().setSoTimeout(DEFAULT_TIMEOUT); if (Jenkins.getInstance() != null) { ProxyConfiguration proxy = Jenkins.getInstance().proxy;