diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-10-19 16:47:57 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-23 08:01:13 -0700 |
commit | 32d488c3c81ac9642c6f23fb5f4c64295b921704 (patch) | |
tree | 7385f96ceeaffef9144b3f79eb15868b47009878 /server | |
parent | ce62423f5362fd1c126d6d4e944dfe553744b9b6 (diff) | |
download | sonarqube-32d488c3c81ac9642c6f23fb5f4c64295b921704.tar.gz sonarqube-32d488c3c81ac9642c6f23fb5f4c64295b921704.zip |
SONAR-9946 Background download and "pre-installation" of an edition
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java index bba40e79e3c..f13731a6480 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java @@ -24,7 +24,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Set; -import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.Semaphore; import java.util.stream.Collectors; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -38,7 +38,7 @@ import org.sonar.updatecenter.common.UpdateCenter; public class EditionInstaller { private static final Logger LOG = Loggers.get(EditionInstaller.class); - private final ReentrantLock lock = new ReentrantLock(); + private final Semaphore semaphore = new Semaphore(1); private final EditionInstallerExecutor executor; private final EditionPluginDownloader editionPluginDownloader; private final EditionPluginUninstaller editionPluginUninstaller; @@ -64,7 +64,7 @@ public class EditionInstaller { * @throws IllegalStateException if an installation is already in progress */ public void install(License newLicense) { - if (lock.tryLock()) { + if (semaphore.tryAcquire()) { try { Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true); if (!updateCenter.isPresent()) { @@ -74,7 +74,7 @@ public class EditionInstaller { editionManagementState.startAutomaticInstall(newLicense); executor.execute(() -> asyncInstall(newLicense, updateCenter.get())); } catch (RuntimeException e) { - lock.unlock(); + semaphore.release(); throw e; } } else { @@ -117,7 +117,7 @@ public class EditionInstaller { LOG.error("Failed to install edition {} with plugins {}", newLicense.getEditionKey(), newLicense.getPluginKeys(), t); editionManagementState.installFailed(t.getMessage()); } finally { - lock.unlock(); + semaphore.release(); } } |