From 25c2f095ebb42c037573779652fbcb87faa38d18 Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Mon, 27 Feb 2017 17:34:48 +0530 Subject: [PATCH] Call disconnect() on HttpURLConnection object Release the network resource(s) held by the underlying connection(s?): - during retry attempts - after obtaining the JNLP connection arguments --- src/main/java/hudson/remoting/Launcher.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/remoting/Launcher.java b/src/main/java/hudson/remoting/Launcher.java index b9f96efbe..a63bb8b45 100644 --- a/src/main/java/hudson/remoting/Launcher.java +++ b/src/main/java/hudson/remoting/Launcher.java @@ -376,8 +376,9 @@ public List parseJnlpArguments() throws ParserConfigurationException, SA } } while (true) { + URLConnection con = null; try { - URLConnection con = Util.openURLConnection(slaveJnlpURL); + con = Util.openURLConnection(slaveJnlpURL); if (con instanceof HttpURLConnection) { HttpURLConnection http = (HttpURLConnection) con; if (slaveJnlpCredentials != null) { @@ -462,6 +463,11 @@ public List parseJnlpArguments() throws ParserConfigurationException, SA System.err.println("Waiting 10 seconds before retry"); Thread.sleep(10*1000); // retry + } finally { + if (con instanceof HttpURLConnection) { + HttpURLConnection http = (HttpURLConnection) con; + http.disconnect(); + } } } }