diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-10-19 14:30:57 +0200 |
---|---|---|
committer | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2017-10-23 08:01:13 -0700 |
commit | e8475ad355de1e007ad08a795f31edd0dc8c7271 (patch) | |
tree | 784319705ec1b2744fff1e636f8bceb4a634fbcf /server | |
parent | 69d79bcad21aa2ad801e3e05e4163b89071936b6 (diff) | |
download | sonarqube-e8475ad355de1e007ad08a795f31edd0dc8c7271.tar.gz sonarqube-e8475ad355de1e007ad08a795f31edd0dc8c7271.zip |
SONAR-9939 Don't refresh update center on edition preview
Diffstat (limited to 'server')
3 files changed, 8 insertions, 2 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/edition/ws/PreviewAction.java b/server/sonar-server/src/main/java/org/sonar/server/edition/ws/PreviewAction.java index e5de17fa81a..399d0fc311d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/edition/ws/PreviewAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/edition/ws/PreviewAction.java @@ -93,6 +93,8 @@ public class PreviewAction implements EditionsWsAction { private NextState computeNextState(License newLicense) { if (!editionInstaller.requiresInstallationChange(newLicense.getPluginKeys())) { return new NextState(newLicense.getEditionKey(), NO_INSTALL); + // this won't refresh the update center (uses cached state). Preview is called while typing (must be fast) + // and anyway the status is refreshed when arriving at the marketplace page. } else if (editionInstaller.isOffline()) { return new NextState(newLicense.getEditionKey(), MANUAL_INSTALL); } else { 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 f72e157ee45..5fac04557c2 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 @@ -82,8 +82,12 @@ public class EditionInstaller { uninstallPlugins(pluginsToRemove); } + /** + * Check if the update center is disabled or unreachable. It uses the cached status (it doesn't refresh), + * to be a cost-free check. + */ public boolean isOffline() { - return !updateCenterMatrixFactory.getUpdateCenter(true).isPresent(); + return !updateCenterMatrixFactory.getUpdateCenter(false).isPresent(); } public boolean requiresInstallationChange(Set<String> editionPluginKeys) { diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java index e4c0603642f..b897d1b131f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java @@ -122,7 +122,7 @@ public class EditionInstallerTest { @Test public void is_offline() { - when(updateCenterMatrixFactory.getUpdateCenter(true)).thenReturn(Optional.absent()); + when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.absent()); assertThat(installer.isOffline()).isTrue(); } |