]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7121 Project's File Lock not released on error 705/head
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 6 Jan 2016 13:17:53 +0000 (14:17 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 6 Jan 2016 15:19:19 +0000 (16:19 +0100)
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java

index 63485f49f08b44420c9c0c07e889a8dab6a7d1ce..da67178b802b40776db7cf6926e5af6201b59cc7 100644 (file)
@@ -99,6 +99,7 @@ public class ProjectScanContainer extends ComponentContainer {
   private static final Logger LOG = Loggers.get(ProjectScanContainer.class);
 
   private final AnalysisProperties props;
+  private ProjectLock lock;
 
   public ProjectScanContainer(ComponentContainer globalContainer, AnalysisProperties props) {
     super(globalContainer);
@@ -108,7 +109,8 @@ public class ProjectScanContainer extends ComponentContainer {
   @Override
   protected void doBeforeStart() {
     addBatchComponents();
-    getComponentByType(ProjectLock.class).tryLock();
+    lock = getComponentByType(ProjectLock.class);
+    lock.tryLock();
     addBatchExtensions();
     Settings settings = getComponentByType(Settings.class);
     if (settings != null && settings.getBoolean(CoreProperties.PROFILING_LOG_PROPERTY)) {
@@ -125,7 +127,6 @@ public class ProjectScanContainer extends ComponentContainer {
       return super.startComponents();
     } catch (Exception e) {
       // ensure that lock is released
-      ProjectLock lock = getComponentByType(ProjectLock.class);
       if (lock != null) {
         lock.stop();
       }