[ https://issues.apache.org/jira/browse/HBASE-25037?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17196814#comment-17196814 ]
Viraj Jasani edited comment on HBASE-25037 at 9/16/20, 9:28 AM: ---------------------------------------------------------------- Thanks [~zhangduo] for finding this issue. {code:java} public static ThreadFactory newDaemonThreadFactory(final String prefix, final UncaughtExceptionHandler handler) { final ThreadFactory namedFactory = getNamedThreadFactory(prefix); return new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = namedFactory.newThread(r); if (handler != null) { t.setUncaughtExceptionHandler(handler); } else { t.setUncaughtExceptionHandler(LOGGING_EXCEPTION_HANDLER); } if (!t.isDaemon()) { t.setDaemon(true); } if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } return t; } }; } {code} Everyone using previous utility always used to have daemon mode on. To maintain the same behaviour, I agree that we will have to update all thread factories to use daemon threads. Ideally, even for this previous utility, daemon mode as boolean flag should have been part of the method signature though so that client can make better decision while using this utility. was (Author: vjasani): {code:java} public static ThreadFactory newDaemonThreadFactory(final String prefix, final UncaughtExceptionHandler handler) { final ThreadFactory namedFactory = getNamedThreadFactory(prefix); return new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = namedFactory.newThread(r); if (handler != null) { t.setUncaughtExceptionHandler(handler); } else { t.setUncaughtExceptionHandler(LOGGING_EXCEPTION_HANDLER); } if (!t.isDaemon()) { t.setDaemon(true); } if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } return t; } }; } {code} Everyone using previous utility always used to have daemon mode on. To maintain the same behaviour, I agree that we will have to update all thread factories to use daemon threads. Ideally, even for this previous utility, daemon mode as boolean flag should have been part of the method signature though so that client can make better decision while using this utility. > Lots of thread pool are changed to non daemon after HBASE-24750 which causes > trouble when shutting down > ------------------------------------------------------------------------------------------------------- > > Key: HBASE-25037 > URL: https://issues.apache.org/jira/browse/HBASE-25037 > Project: HBase > Issue Type: Improvement > Reporter: Duo Zhang > Assignee: Duo Zhang > Priority: Major > Fix For: 3.0.0-alpha-1, 2.4.0 > > > We replace Threads.newDaemonThreadFactory with guava ThreadFactoryBuilder but > miss the setDaemon call, which causes our client integration test to fail > because of hbase shell can never quit cleanly. > We should add the setDaemon back for those thread factories. -- This message was sent by Atlassian Jira (v8.3.4#803005)