diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java index 8951e0f4bcc6b..e81c2718bac28 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/io/gridnioserver/GridNioClientConnectionMultiplexer.java @@ -146,8 +146,31 @@ 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 ignored) { + // ignore close exception + } + } + + try { + ch.close(); + } + catch (Exception ignored) { + // ignore close exception + } + } + throw new ClientConnectionException(e.getMessage(), e); + } Map meta = new HashMap<>(); GridNioFuture sslHandshakeFut = null;