GitHub user tombentley opened a pull request: https://github.com/apache/kafka/pull/3395
KAFKA-3575: Use console consumer access topic that does not exist, ca⦠â¦n not use "Control + C" to exit process A finally block is not guaranteed to execute in the event of Ctrl+C happening while in the try or catch blocks. Decrementing the latch in the finally block therefore made the shutdown hook hang waiting for something that would never happen and the JVM couldn't exit while it was running the shutdown hook. Replacing the latch with an atomic flag to say whether we've run the cleanup code allows us to either run it from the shutdown hook, or the finally block. It should thus definitely run once. When run from the shutdown hook the main thread would no longer be running, so it should be threadsafe. The contribution is my original work and I license the work to the project under the project's open source license. You can merge this pull request into a Git repository by running: $ git pull https://github.com/tombentley/kafka KAFKA-3575 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/3395.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3395 ---- commit 66b1ff6d37d0eab36e00f1251d0463a7b13cd11d Author: Tom Bentley <tbent...@redhat.com> Date: 2017-06-21T11:11:27Z KAFKA-3575: Use console consumer access topic that does not exist, can not use "Control + C" to exit process A finally block is not guaranteed to execute in the event of Ctrl+C happening while in the try or catch blocks. Decrementing the latch in the finally block therefore made the shutdown hook hang waiting for something that would never happen and the JVM couldn't exit while it was running the shutdown hook. Replacing the latch with an atomic flag to say whether we've run the cleanup code allows us to either run it from the shutdown hook, or the finally block. It should thus definitely run once. When run from the shutdown hook the main thread would no longer be running, so it should be threadsafe. ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---