From 0d9fcaa4415ee996e423a97cfe0d965586ca59a5 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 25 Jun 2015 16:04:22 +0200 Subject: [PATCH] SONAR-6649 Stop components from global container in case of error --- .../java/org/sonar/batch/bootstrapper/Batch.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java index 044678ed0a0..fa261e9176c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -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; } -- 2.39.5