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;

public class HttpConnectorWithJenkinsProxy implements HttpConnector {
    public HttpURLConnection connect(URL url) throws IOException {
        return (HttpURLConnection) ProxyConfiguration.open(url);
    }
}

@@ -42,76 +42,63 @@
 ort 
-hudson.ProxyConfiguration;%0Aimport org.kohsuke.github
+java.io.IOException;%0Aimport java.net
 .Http
+URL
 Connect
-or;%0A
+ion;
 %0Aimp
@@ -110,66 +110,67 @@
 ava.
-io.IOException;%0Aimport java.net
+net.URL;%0A%0Aimport org.kohsuke.github
 .Http
-URL
 Connect
-ion;
+or;%0A
 %0Aimport 
 java
@@ -165,28 +165,41 @@
 %0Aimport 
-java.net.URL
+hudson.ProxyConfiguration
 ;%0A%0Apubli
@@ -342,14 +342,31 @@
     
-return
+HttpURLConnection con =
  (Ht
@@ -411,16 +411,278 @@
 en(url);
+%0A%0A        // Set default timeouts in case there are none%0A        if (con.getConnectTimeout() == 0) %7B%0A            con.setConnectTimeout(10000);%0A        %7D%0A        if (con.getReadTimeout() == 0) %7B%0A            con.setReadTimeout(10000);%0A        %7D%0A        return con;
 %0A    %7D%0A%7D

Use default timeouts for URLConnections