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 <[email protected]>
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 <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>, Michael Han
<[email protected]>, Damien Diederen <[email protected]>
Closes #1705 from franz1981/ZOOKEEPER-4309
(cherry picked from commit 78550453204e89a13aee87d86b6d94c458c9dd63)
Signed-off-by: Enrico Olivelli <[email protected]>
---
.../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();