Skip to content

Commit b17a983

Browse files
committed
Clean shutdown hook in performance test
It triggers a latch, so removing it once the latch is completed.
1 parent 09efe3f commit b17a983

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/rabbitmq/stream/perf/StreamPerfTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,12 @@ public Integer call() throws Exception {
936936
shutdownService.wrap(closeStep("Closing metrics", () -> this.performanceMetrics.close()));
937937

938938
CountDownLatch latch = new CountDownLatch(1);
939-
Runtime.getRuntime().addShutdownHook(new Thread(() -> latch.countDown()));
939+
940+
Thread shutdownHook = new Thread(() -> latch.countDown());
941+
Runtime.getRuntime().addShutdownHook(shutdownHook);
940942
try {
941943
latch.await();
944+
Runtime.getRuntime().removeShutdownHook(shutdownHook);
942945
} catch (InterruptedException e) {
943946
// moving on to the closing sequence
944947
}

0 commit comments

Comments
 (0)