Skip to content

Commit

Permalink
chore: adding finally to shutdown hook
Browse files Browse the repository at this point in the history
  • Loading branch information
sauljabin committed Jan 31, 2024
1 parent 138c4da commit 0569af8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions canary/src/main/java/io/littlehorse/canary/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}));
}
}

0 comments on commit 0569af8

Please sign in to comment.