src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPChannel.java

Print this page

        

@@ -294,16 +294,20 @@
                     }
 
                     out.flush();
                 }
             } catch (IOException e) {
-                if (e instanceof RemoteException)
+                try {
+                    conn.close();
+                } catch (Exception ex) {}
+                if (e instanceof RemoteException) {
                     throw (RemoteException) e;
-                else
+                } else {
                     throw new ConnectIOException(
                         "error during JRMP connection establishment", e);
             }
+            }
         } else {
             try {
                 conn = multiplexer.openConnection();
             } catch (IOException e) {
                 synchronized (this) {