We encountered a general deaklock issue with System.exit(), where a startup / shutdown aware container wrapping KafkaServerStartable that has shutdown hook executed by another thread is blocked waiting for the main thread in startup() to set the startup_finished flag while the main thread is blocked on waiting for the shutdown hook thread to join.
So I would like to propose a bit different solution:
1. Replace System.exit(1) in startup with the shutdown() call.
2. In KafkaServer.shutdown, move
to the final block.
3. Remove the System.exit(1) in shutdown() call.
This will resolve this issue but as well works with a startup / shutdown aware container that has a shutdown hook depending on the startup logic to be complete.