From 2f402211d9452b8610b0159366ce9cddcc0bafd2 Mon Sep 17 00:00:00 2001 From: Rob McKenna Date: Wed, 24 May 2017 17:25:45 +0100 Subject: [PATCH] 8175131: sun.rmi.transport.tcp.TCPChannel.createConnection close connection on timeout Reviewed-by: rriggs, msheppar --- .../classes/sun/rmi/transport/tcp/TCPChannel.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java index d073e890737..1f4f94a98d3 100644 --- a/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java +++ b/jdk/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java @@ -296,11 +296,19 @@ public class TCPChannel implements Channel { out.flush(); } } catch (IOException e) { - if (e instanceof RemoteException) + if (e instanceof RemoteException) { throw (RemoteException) e; - else + } else { + if (conn != null + && e instanceof java.net.SocketTimeoutException) + { + try { + conn.close(); + } catch (Exception ex) {} + } throw new ConnectIOException( "error during JRMP connection establishment", e); + } } } else { try {