jiafu1115 commented on PR #20007: URL: https://github.com/apache/kafka/pull/20007#issuecomment-3028329624
@kamalcph I double checked all the shutdown's related code and found that the lucky thing is that we already have one ShutdownHook to shutdown the service gracefully. So it should be safe to call Exit.exit(). cc @FrankYang0529 @showuon https://github.com/apache/kafka/blob/42041f47729947dc9da0302cb3b747427f5cef97/core/src/main/scala/kafka/Kafka.scala#L87-L97 BTW: I write some similar codes to verify it: ``` public static void main(String[] args) { final Thread hook = new Thread( () -> { System.out.println("hook execute start"); sleep(10); System.out.println("hook execute complete"); } ); hook.setDaemon(false); Runtime.getRuntime().addShutdownHook(hook); System.out.println("begin to start the server"); startup(); System.out.println("end to start the server"); sleep(100); } private static void startup() { new Thread(() -> { sleep(10); System.out.println("begin to call exit"); System.exit(1); System.out.println("complete to call exit"); }).start(); } public static void sleep(int seconds) { try { TimeUnit.SECONDS.sleep(seconds); } catch (InterruptedException e) { // } } ``` Test result: ``` begin to start the server end to start the server begin to call exit hook execute start hook execute complete ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org