From 5134ded8eb0fe6ec498c4836853f7fb90f8b0c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Tue, 1 Dec 2015 15:25:26 +0100 Subject: [PATCH] [JENKINS-31827] Use default timeouts for URLConnections --- .../ghprb/HttpConnectorWithJenkinsProxy.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java b/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java index f44dacf67..256db4c78 100644 --- a/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java +++ b/src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java @@ -1,14 +1,24 @@ package org.jenkinsci.plugins.ghprb; -import hudson.ProxyConfiguration; -import org.kohsuke.github.HttpConnector; - import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import org.kohsuke.github.HttpConnector; + +import hudson.ProxyConfiguration; + public class HttpConnectorWithJenkinsProxy implements HttpConnector { public HttpURLConnection connect(URL url) throws IOException { - return (HttpURLConnection) ProxyConfiguration.open(url); + HttpURLConnection con = (HttpURLConnection) ProxyConfiguration.open(url); + + // Set default timeouts in case there are none + if (con.getConnectTimeout() == 0) { + con.setConnectTimeout(10000); + } + if (con.getReadTimeout() == 0) { + con.setReadTimeout(10000); + } + return con; } }