diff options
| author | 2026-08-19 09:31:13 +0200 | |
|---|---|---|
| committer | 2026-08-19 16:39:15 +0200 | |
| commit | 22d41d919adcab0626a66e8ecc162afe233afc7b (patch) | |
| tree | e305f7e66698fa61738a9f05b1d3844d21870ba8 | |
| parent | 91a38847280eab6ae0cef016a6034136c71ff44b (diff) | |
exitcode Variable needed because finally block does not run after exit
Use System.exit only if return code is !=0
| -rw-r--r-- | src/main/java/com/it_jaros/jns/App.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/it_jaros/jns/App.java b/src/main/java/com/it_jaros/jns/App.java index 166715d..7fb2415 100644 --- a/src/main/java/com/it_jaros/jns/App.java +++ b/src/main/java/com/it_jaros/jns/App.java @@ -13,17 +13,22 @@ public class App { private static final CountDownLatch shutdownLatch = new CountDownLatch(1); public static void main(String[] args) { + int exitCode = 0; try { run(args); } catch (HelpRequested e) { // Do nothing } catch (Exception e) { System.err.println(e.getMessage()); - System.exit(1); + exitCode = 1; } finally { shutdownLatch.countDown(); removeShutdownHook(); } + + if (exitCode != 0) { + System.exit(exitCode); + } } private static void run(String[] args) throws Exception { |
