Skip to content

Commit d73d4e1

Browse files
Merge pull request #216 from rabbitmq/rabbitmq-perf-test-215-always-call-system-exit
Make sure to always call System#exit
2 parents f2c8aa6 + 41f1569 commit d73d4e1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/rabbitmq/perf/PerfTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public static void main(String [] args, PerfTestOptions perfTestOptions) {
5656
shutdownService.wrap(() -> metrics.close());
5757
Options metricsOptions = metrics.options();
5858
forEach(metricsOptions, option -> options.addOption(option));
59+
int exitStatus = 0;
5960
try {
6061
CommandLine rawCmd = parser.parse(options, args);
6162
CommandLineProxy cmd = new CommandLineProxy(options, rawCmd, perfTestOptions.argumentLookup);
@@ -325,17 +326,18 @@ public static void main(String [] args, PerfTestOptions perfTestOptions) {
325326
set.run(true);
326327

327328
stats.printFinal();
328-
}
329-
catch (ParseException exp) {
329+
} catch (ParseException exp) {
330330
System.err.println("Parsing failed. Reason: " + exp.getMessage());
331331
usage(options);
332332
} catch (Exception e) {
333333
System.err.println("Main thread caught exception: " + e);
334334
LOGGER.error("Main thread caught exception", e);
335-
systemExiter.exit(1);
335+
exitStatus = 1;
336336
} finally {
337337
shutdownService.close();
338338
}
339+
// we need to exit explicitly, without waiting alive threads (e.g. when using --shutdown-timeout 0)
340+
systemExiter.exit(exitStatus);
339341
}
340342

341343
private static PrintWriter openCsvFileForWriting(String outputFile, ShutdownService shutdownService) throws IOException {

0 commit comments

Comments
 (0)