From commits-return-8457-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Tue Jul 28 08:30:14 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 3CCD5180665 for ; Tue, 28 Jul 2020 10:30:14 +0200 (CEST) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 1A786124CF7 for ; Tue, 28 Jul 2020 08:30:08 +0000 (UTC) Received: (qmail 76312 invoked by uid 500); 28 Jul 2020 08:30:05 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 76300 invoked by uid 99); 28 Jul 2020 08:30:05 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2020 08:30:05 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id BBBFA82072; Tue, 28 Jul 2020 08:30:04 +0000 (UTC) Date: Tue, 28 Jul 2020 08:30:04 +0000 To: "commits@zookeeper.apache.org" Subject: [zookeeper] branch master updated: ZOOKEEPER-3112: fix fd leak due to UnresolvedAddressException on connect MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <159592500437.13989.3557505574668607807@gitbox.apache.org> From: symat@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: zookeeper X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 1c41e127537f66842515ccb21fb48f1670003454 X-Git-Newrev: 6a8728d98307f7d52cf6dbadb78149e01b1d0bf5 X-Git-Rev: 6a8728d98307f7d52cf6dbadb78149e01b1d0bf5 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. symat pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/zookeeper.git The following commit(s) were added to refs/heads/master by this push: new 6a8728d ZOOKEEPER-3112: fix fd leak due to UnresolvedAddressException on connect 6a8728d is described below commit 6a8728d98307f7d52cf6dbadb78149e01b1d0bf5 Author: Alexey.Saltanov AuthorDate: Tue Jul 28 08:29:28 2020 +0000 ZOOKEEPER-3112: fix fd leak due to UnresolvedAddressException on connect SocketChannel.connect() can throw different kind of exceptions but ClientCnxnSocketNIO.connect() handles only IOException. This could lead to FD leak when socked is opened but is not connected. We should handle some additional exception classes and close the socket. Author: Alexey.Saltanov Reviewers: Enrico Olivelli , Mate Szalay-Beko Closes #1410 from saltos/ZOOKEEPER-3112 --- .../src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java index 1fe53a3..6cb125d 100644 --- a/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java +++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java @@ -26,6 +26,8 @@ import java.nio.ByteBuffer; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; +import java.nio.channels.UnresolvedAddressException; +import java.nio.channels.UnsupportedAddressTypeException; import java.util.Iterator; import java.util.Queue; import java.util.Set; @@ -266,7 +268,7 @@ public class ClientCnxnSocketNIO extends ClientCnxnSocket { SocketChannel sock = createSock(); try { registerAndConnect(sock, addr); - } catch (IOException e) { + } catch (UnresolvedAddressException | UnsupportedAddressTypeException | SecurityException | IOException e) { LOG.error("Unable to open socket to {}", addr); sock.close(); throw e;