forked from jenkinsci/gitlab-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jenkinsci#234 from olivergondza/socket-timeout
[JENKINS-31827] Use default timeouts for URLConnections
- Loading branch information
Showing
1 changed file
with
14 additions
and
4 deletions.
There are no files selected for viewing
18 changes: 14 additions & 4 deletions
18
src/main/java/org/jenkinsci/plugins/ghprb/HttpConnectorWithJenkinsProxy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |