ptupitsyn commented on code in PR #11016:
URL: https://github.com/apache/ignite/pull/11016#discussion_r1373341980


##########
modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java:
##########
@@ -146,8 +146,30 @@ public 
GridNioClientConnectionMultiplexer(ClientConfiguration cfg) {
         rwLock.readLock().lock();
 
         try {
-            SocketChannel ch = SocketChannel.open();
-            ch.socket().connect(new InetSocketAddress(addr.getHostName(), 
addr.getPort()), connTimeout);
+            SocketChannel ch = null;
+            try {
+                ch = SocketChannel.open();
+                ch.socket().connect(new InetSocketAddress(addr.getHostName(), 
addr.getPort()), connTimeout);
+            }
+            catch (Exception e) {
+                if (ch != null) {
+                    if (ch.socket() != null) {
+                        try {
+                            ch.socket().close();
+                        }
+                        catch (Exception ex) {
+                            throw new 
ClientConnectionException(ex.getMessage(), ex);
+                        }
+                    }
+                    try {
+                        ch.close();
+                    }
+                    catch (Exception ex) {
+                        throw new ClientConnectionException(ex.getMessage(), 
ex);
+                    }
+                }

Review Comment:
   ```suggestion
                   if (ch != null) {
                       if (ch.socket() != null) {
                           try {
                               ch.socket().close();
                           }
                           catch (Exception ignored) {
                           }
                       }
                       
                       try {
                           ch.close();
                       }
                       catch (Exception ignored) {
                       }
                   }
   ```
   
   The idea is to throw the original exception to the user. We don't care about 
exceptions that happen int `close()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to