vlsi commented on a change in pull request #1625: DRILL-7008: Drillbits: clear stale shutdown hooks URL: https://github.com/apache/drill/pull/1625#discussion_r251374378
########## File path: exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java ########## @@ -258,6 +260,13 @@ public synchronized void close() { } final Stopwatch w = Stopwatch.createStarted(); logger.debug("Shutdown begun."); + // We don't really want for Drillbits to pile up in memory, so the hook should be removed + // It might be better to use PhantomReferences to cleanup as soon as Drillbit becomes + // unreachable, however current approach seems to be good enough. + Thread shutdownHook = this.shutdownHook; + if (shutdownHook != null && Thread.currentThread() != shutdownHook) { + Runtime.getRuntime().removeShutdownHook(shutdownHook); Review comment: \@arina-ielchiieva , it is handled by `Thread.currentThread() != shutdownHook`, isn't it? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services