aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-01-13 10:18:35 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2017-01-13 10:22:24 +0100
commit900b0083b6fe8f2df2b6679eefbdb01b41ecd35f (patch)
tree066e00e65ad224f64b3c0417e367e8d201c041d4
parentac866e44647d4e4e793c58ab35796448ea5cf185 (diff)
downloadsonar-scanner-cli-900b0083b6fe8f2df2b6679eefbdb01b41ecd35f.tar.gz
sonar-scanner-cli-900b0083b6fe8f2df2b6679eefbdb01b41ecd35f.zip
SQSCANNER-36 Properly exit process even in case of failure during stop
-rw-r--r--src/main/java/org/sonarsource/scanner/cli/Main.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java
index f825034..8d030e4 100644
--- a/src/main/java/org/sonarsource/scanner/cli/Main.java
+++ b/src/main/java/org/sonarsource/scanner/cli/Main.java
@@ -64,6 +64,7 @@ public class Main {
void execute() {
Stats stats = new Stats(logger).start();
+ int status = Exit.ERROR;
try {
Properties p = conf.properties();
checkSkip(p);
@@ -72,14 +73,22 @@ public class Main {
runner.start();
logger.info("SonarQube server " + runner.serverVersion());
runAnalysis(stats, p);
+ status = Exit.SUCCESS;
} catch (Exception e) {
+ status = Exit.ERROR;
displayExecutionResult(stats, "FAILURE");
showError("Error during SonarQube Scanner execution", e, cli.isDebugEnabled());
- exit.exit(Exit.ERROR);
+ } finally {
+ try {
+ runner.stop();
+ } catch (Throwable e) {
+ status = Exit.ERROR;
+ logger.error("Unable to properly stop the scanner", e);
+ } finally {
+ exit.exit(status);
+ }
}
- runner.stop();
- exit.exit(Exit.SUCCESS);
}
private void checkSkip(Properties properties) {