Skip to content

Commit 0f1a204

Browse files
committed
Clean shutdown hook in performance test
The hook for the shutdown service. It is now removed once the shutdown service has run.
1 parent 3982b84 commit 0f1a204

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ public Integer call() throws Exception {
560560
this.messageSize = this.messageSize < 8 ? 8 : this.messageSize; // we need to store a long in it
561561

562562
ShutdownService shutdownService = new ShutdownService();
563+
Thread shutdownServiceShutdownHook = new Thread(() -> shutdownService.close());
564+
Runtime.getRuntime().addShutdownHook(shutdownServiceShutdownHook);
563565

564566
try {
565567

@@ -570,8 +572,6 @@ public Integer call() throws Exception {
570572

571573
shutdownService.wrap(closeStep("Closing monitoring context", monitoringContext::close));
572574

573-
Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdownService.close()));
574-
575575
// FIXME add confirm latency
576576

577577
ScheduledExecutorService envExecutor =
@@ -958,6 +958,7 @@ public Integer call() throws Exception {
958958
}
959959
} finally {
960960
shutdownService.close();
961+
Runtime.getRuntime().removeShutdownHook(shutdownServiceShutdownHook);
961962
}
962963

963964
return 0;

0 commit comments

Comments
 (0)