From 806f670a1f3e881715408d86d03ca93a72e6d142 Mon Sep 17 00:00:00 2001 From: Oleg Nenashev Date: Thu, 9 Jun 2016 12:07:59 +0200 Subject: [PATCH] [JENKINS-31256] - minor code improvements --- src/main/java/hudson/remoting/Engine.java | 4 +++- src/main/java/hudson/remoting/Util.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/hudson/remoting/Engine.java b/src/main/java/hudson/remoting/Engine.java index 90a622101..276188ad4 100644 --- a/src/main/java/hudson/remoting/Engine.java +++ b/src/main/java/hudson/remoting/Engine.java @@ -214,7 +214,7 @@ public void run() { Throwable firstError=null; String host=null; String port=null; - SSLSocketFactory sslSocketFactory = getSSLSocketFactory(); + final SSLSocketFactory sslSocketFactory = getSSLSocketFactory(); for (URL url : candidateUrls) { String s = url.toExternalForm(); @@ -554,6 +554,7 @@ public FileInputStream run() throws Exception { }); } + @CheckForNull private SSLSocketFactory getSSLSocketFactory() throws PrivilegedActionException, KeyStoreException, NoSuchProviderException, CertificateException, NoSuchAlgorithmException, IOException, KeyManagementException { @@ -578,6 +579,7 @@ private SSLSocketFactory getSSLSocketFactory() } return sslSocketFactory; } + //a read() call on the SocketInputStream associated with underlying Socket will block for only this amount of time static final int SOCKET_TIMEOUT = Integer.getInteger(Engine.class.getName()+".socketTimeout",30*60*1000); /** diff --git a/src/main/java/hudson/remoting/Util.java b/src/main/java/hudson/remoting/Util.java index 57fca72f0..48850991b 100644 --- a/src/main/java/hudson/remoting/Util.java +++ b/src/main/java/hudson/remoting/Util.java @@ -17,6 +17,7 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; import java.util.Iterator; +import javax.annotation.CheckForNull; /** * Misc. I/O utilities @@ -163,7 +164,8 @@ static boolean inNoProxyEnvVar(String host) { * If http_proxy environment variable exists, the connection uses the proxy. * Credentials can be passed e.g. to support running Jenkins behind a (reverse) proxy requiring authorization */ - static URLConnection openURLConnection(URL url, String credentials, String proxyCredentials, SSLSocketFactory sslSocketFactory) throws IOException { + static URLConnection openURLConnection(URL url, String credentials, String proxyCredentials, + @CheckForNull SSLSocketFactory sslSocketFactory) throws IOException { String httpProxy = null; // If http.proxyHost property exists, openConnection() uses it. if (System.getProperty("http.proxyHost") == null) {