From 0569af8a146c263fb9f965ee442aa5729e0fec35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Pi=C3=B1a?= Date: Wed, 31 Jan 2024 14:58:19 -0500 Subject: [PATCH] chore: adding finally to shutdown hook --- canary/src/main/java/io/littlehorse/canary/Main.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/canary/src/main/java/io/littlehorse/canary/Main.java b/canary/src/main/java/io/littlehorse/canary/Main.java index 6752ee372..72797738c 100644 --- a/canary/src/main/java/io/littlehorse/canary/Main.java +++ b/canary/src/main/java/io/littlehorse/canary/Main.java @@ -71,8 +71,13 @@ private static void initiateKafkaTopicBootstrap(CanaryConfig config, CountDownLa private static void addShutdownHook(Bootstrap bootstrap, CountDownLatch latch) { Runtime.getRuntime().addShutdownHook(new Thread(() -> { log.trace("{} shutdown process started", bootstrap.getClass().getSimpleName()); - bootstrap.shutdown(); - latch.countDown(); + try { + bootstrap.shutdown(); + } catch (Exception e) { + log.error("Error in ShutdownHook '{}'", bootstrap.getClass().getSimpleName(), e); + } finally { + latch.countDown(); + } })); } }