changeset 17162:d0d971960744

8175131: sun.rmi.transport.tcp.TCPChannel.createConnection close connection on timeout Reviewed-by: rriggs, msheppar
author robm
date Wed, 24 May 2017 17:25:45 +0100
parents 47032f7eebb1
children c162df937880
files src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java	Tue May 23 14:34:45 2017 -0700
+++ b/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java	Wed May 24 17:25:45 2017 +0100
@@ -296,11 +296,19 @@
                     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 {