You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by eo...@apache.org on 2021/06/14 09:46:22 UTC

[zookeeper] branch branch-3.7 updated: ZOOKEEPER-4309: QuorumCnxManager's ListenerHandler thread leak

This is an automated email from the ASF dual-hosted git repository.

eolivelli pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/branch-3.7 by this push:
     new 7048d3a  ZOOKEEPER-4309: QuorumCnxManager's ListenerHandler thread leak
7048d3a is described below

commit 7048d3a583eff4fff88d5071f5427a2ad36c1acf
Author: franz1981 <ni...@gmail.com>
AuthorDate: Mon Jun 14 11:45:58 2021 +0200

    ZOOKEEPER-4309: QuorumCnxManager's ListenerHandler thread leak
    
    https://issues.apache.org/jira/browse/ZOOKEEPER-4309
    
    Author: franz1981 <ni...@gmail.com>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>, Michael Han <ha...@apache.org>, Damien Diederen <dd...@apache.org>
    
    Closes #1705 from franz1981/ZOOKEEPER-4309
    
    (cherry picked from commit 78550453204e89a13aee87d86b6d94c458c9dd63)
    Signed-off-by: Enrico Olivelli <eo...@apache.org>
---
 .../org/apache/zookeeper/server/quorum/QuorumCnxManager.java     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
index 2f240e9..6bb611f 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
@@ -957,8 +957,13 @@ public class QuorumCnxManager {
                                 new ListenerHandler(address, self.shouldUsePortUnification(), self.isSslQuorum(), latch))
                         .collect(Collectors.toList());
 
-                ExecutorService executor = Executors.newFixedThreadPool(addresses.size());
-                listenerHandlers.forEach(executor::submit);
+                final ExecutorService executor = Executors.newFixedThreadPool(addresses.size());
+                try {
+                    listenerHandlers.forEach(executor::submit);
+                } finally {
+                    // prevent executor's threads to leak after ListenerHandler tasks complete
+                    executor.shutdown();
+                }
 
                 try {
                     latch.await();