Skip to content

Commit

Permalink
Merge pull request jenkinsci#234 from olivergondza/socket-timeout
Browse files Browse the repository at this point in the history
[JENKINS-31827] Use default timeouts for URLConnections
  • Loading branch information
DavidTanner committed Dec 1, 2015
2 parents 789cee5 + 5134ded commit ca3b37a
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit ca3b37a

Please sign in to comment.