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

hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/master by this push:
     new 3b49f55  Daemonize ZkBucketDataAccessor GC_THREAD (#1936)
3b49f55 is described below

commit 3b49f55df298e1d12daa078034137f58543319e5
Author: Henri Hagberg <[email protected]>
AuthorDate: Wed Jan 19 00:30:13 2022 +0200

    Daemonize ZkBucketDataAccessor GC_THREAD (#1936)
    
    GC_THREAD (which is actually an ExecutorService, not Thread) is a static 
field in ZkBucketDataAccessor. The executor is started when 
ZkBucketDataAccessor class is initialized but it is never shut down. Since 
ExecutorService threads are generally not daemon threads, not shutting down 
GC_THREAD prevents JVM from shutting down cleanly.
    
    This commit makes ZkBucketDataAccessor GC_THREAD a daemon thread so it 
doesn't prevent application shutdown.
---
 .../main/java/org/apache/helix/manager/zk/ZkBucketDataAccessor.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBucketDataAccessor.java
 
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBucketDataAccessor.java
index 2f35994..521e3d7 100644
--- 
a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBucketDataAccessor.java
+++ 
b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkBucketDataAccessor.java
@@ -67,7 +67,11 @@ public class ZkBucketDataAccessor implements 
BucketDataAccessor, AutoCloseable {
   // Note that newScheduledThreadPool(1) may not work. 
newSingleThreadScheduledExecutor guarantees
   // sequential execution, which is what we want for implementing TTL & GC here
   private static final ScheduledExecutorService GC_THREAD =
-      Executors.newSingleThreadScheduledExecutor();
+      Executors.newSingleThreadScheduledExecutor((runnable) -> {
+        Thread thread = new Thread(runnable, "ZkBucketDataAccessorGcThread");
+        thread.setDaemon(true);
+        return thread;
+      });
 
   private final int _bucketSize;
   private final long _versionTTLms;

Reply via email to