]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6517 fix regression - server should stop if plugin is not compatible with SQ...
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 6 May 2015 08:50:08 +0000 (10:50 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 11 May 2015 08:21:56 +0000 (10:21 +0200)
server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java

index cb9db1f40424e3e399115d08c2e2a981aa8f96b2..61258abec8ee2473b276de46051f8e12e8ee31e7 100644 (file)
@@ -226,17 +226,17 @@ public class ServerPluginRepository implements PluginRepository, Startable {
     do {
       removedKeys.clear();
       for (PluginInfo plugin : pluginInfosByKeys.values()) {
+        if (!plugin.isCompatibleWith(server.getVersion())) {
+          throw MessageException.of(String.format(
+            "Plugin %s [%s] requires at least SonarQube %s", plugin.getName(), plugin.getKey(), plugin.getMinimalSqVersion()));
+        }
+
         if (!Strings.isNullOrEmpty(plugin.getBasePlugin()) && !pluginInfosByKeys.containsKey(plugin.getBasePlugin())) {
           // this plugin extends a plugin that is not installed
           LOG.warn("Plugin {} [{}] is ignored because its base plugin [{}] is not installed", plugin.getName(), plugin.getKey(), plugin.getBasePlugin());
           removedKeys.add(plugin.getKey());
         }
 
-        if (!plugin.isCompatibleWith(server.getVersion())) {
-          LOG.warn("Plugin {} [{}] is ignored because it requires at least SonarQube {}", plugin.getName(), plugin.getKey(), plugin.getMinimalSqVersion());
-          removedKeys.add(plugin.getKey());
-        }
-
         for (PluginInfo.RequiredPlugin requiredPlugin : plugin.getRequiredPlugins()) {
           PluginInfo available = pluginInfosByKeys.get(requiredPlugin.getKey());
           if (available == null) {
index ea87cb3af881964d51765dd8f59f5faae4f5ba0d..8046379bca23fac09d371c2eda690fca178aef44 100644 (file)
@@ -215,14 +215,16 @@ public class ServerPluginRepositoryTest {
   }
 
   @Test
-  public void plugin_is_ignored_at_startup_if_unsupported_sq() throws Exception {
+  public void fail_if_plugin_does_not_support_sq_version() throws Exception {
     when(server.getVersion()).thenReturn("1.0");
     copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 
-    underTest.start();
-
-    // plugin requires SQ 4.5.1 but SQ 1.0 is installed
-    assertThat(underTest.getPluginInfos()).isEmpty();
+    try {
+      underTest.start();
+      fail();
+    } catch (MessageException e) {
+      assertThat(e).hasMessage("Plugin Base Plugin [testbase] requires at least SonarQube 4.5.4");
+    }
   }
 
   @Test