]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9939 Don't refresh update center on edition preview
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 19 Oct 2017 12:30:57 +0000 (14:30 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 15:01:13 +0000 (08:01 -0700)
server/sonar-server/src/main/java/org/sonar/server/edition/ws/PreviewAction.java
server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java
server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java

index e5de17fa81a5a25de430a0e8f939258eee97bc47..399d0fc311d7c25d99b8ef93e0e3ded4e10a97f0 100644 (file)
@@ -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 {
index f72e157ee45201a86c1a1ba022a60f9e54c4f662..5fac04557c2015078f8c9ed9596eb31df759c825 100644 (file)
@@ -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) {
index e4c0603642fe04f4eec70cc3017d259f765240ce..b897d1b131fec7c85c6f912b0652f8a47770343b 100644 (file)
@@ -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();
   }