--- old/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java Wed May 24 18:12:24 2017 +++ new/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java Wed May 24 18:12:24 2017 @@ -296,16 +296,12 @@ out.flush(); } } catch (IOException e) { + try { + conn.close(); + } catch (Exception ex) {} if (e instanceof RemoteException) { throw (RemoteException) e; } else { - if (conn != null - && e instanceof java.net.SocketTimeoutException) - { - try { - conn.close(); - } catch (Exception ex) {} - } throw new ConnectIOException( "error during JRMP connection establishment", e); }