]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6649 Stop components from global container in case of error
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 25 Jun 2015 14:04:22 +0000 (16:04 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 25 Jun 2015 14:49:43 +0000 (16:49 +0200)
sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java

index 044678ed0a08f41863c4f426fdd53f099d66ea60..fa261e9176cdd2f269f82197fe4980f46fc70b0e 100644 (file)
@@ -68,7 +68,15 @@ public final class Batch {
   @Deprecated
   public synchronized Batch execute() {
     configureLogging();
-    start().executeTask(bootstrapProperties).stop();
+    start();
+    boolean threw = true;
+    try {
+      executeTask(bootstrapProperties);
+      threw = false;
+    } finally {
+      doStop(threw);
+    }
+
     return this;
   }
 
@@ -104,11 +112,15 @@ public final class Batch {
    * @since 4.4
    */
   public synchronized void stop() {
+    doStop(false);
+  }
+
+  private void doStop(boolean swallowException) {
     if (!started) {
       throw new IllegalStateException("Batch is not started.");
     }
 
-    bootstrapContainer.stopComponents();
+    bootstrapContainer.stopComponents(swallowException);
 
     this.started = false;
   }