From: Julien Lancelot Date: Tue, 22 Mar 2016 16:35:24 +0000 (+0100) Subject: SONAR-7428 Server fail to start if Views, SQALE or Report is installed X-Git-Tag: 5.5-M11~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=31131ead58d8a4d303a356ca960f14f8c69bc7ee;p=sonarqube.git SONAR-7428 Server fail to start if Views, SQALE or Report is installed --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java index 66729394485..b11a7854387 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java @@ -72,7 +72,10 @@ public class ServerPluginRepository implements PluginRepository, Startable { private static final Logger LOG = Loggers.get(ServerPluginRepository.class); private static final String[] JAR_FILE_EXTENSIONS = new String[] {"jar"}; + // List of plugins that are silently removed if installed private static final Set DEFAULT_BLACKLISTED_PLUGINS = ImmutableSet.of("scmactivity", "issuesreport"); + // List of plugins that should prevent the server to finish its startup + private static final Set FORBIDDEN_COMPATIBLE_PLUGINS = ImmutableSet.of("sqale", "report", "views"); private static final Joiner SLASH_JOINER = Joiner.on(" / ").skipNulls(); private final Server server; @@ -157,15 +160,19 @@ public class ServerPluginRepository implements PluginRepository, Startable { } private void registerPluginInfo(PluginInfo info) { - if (blacklistedPluginKeys.contains(info.getKey())) { - LOG.warn("Plugin {} [{}] is blacklisted and is being uninstalled.", info.getName(), info.getKey()); + String pluginKey = info.getKey(); + if (blacklistedPluginKeys.contains(pluginKey)) { + LOG.warn("Plugin {} [{}] is blacklisted and is being uninstalled.", info.getName(), pluginKey); org.sonar.core.util.FileUtils.deleteQuietly(info.getNonNullJarFile()); return; } - PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info); + if (FORBIDDEN_COMPATIBLE_PLUGINS.contains(pluginKey)) { + throw MessageException.of(String.format("Plugin '%s' is no more compatible with this version of SonarQube", pluginKey)); + } + PluginInfo existing = pluginInfosByKeys.put(pluginKey, info); if (existing != null) { throw MessageException.of(format("Found two files for the same plugin [%s]: %s and %s", - info.getKey(), info.getNonNullJarFile().getName(), existing.getNonNullJarFile().getName())); + pluginKey, info.getNonNullJarFile().getName(), existing.getNonNullJarFile().getName())); } } diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java index 31ba885dd95..a6173acd317 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java @@ -30,6 +30,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import org.mockito.Mockito; import org.sonar.api.platform.Server; @@ -48,6 +49,9 @@ import static org.mockito.Mockito.when; public class ServerPluginRepositoryTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Rule public TemporaryFolder temp = new TemporaryFolder(); @@ -309,6 +313,33 @@ public class ServerPluginRepositoryTest { assertThat(logs.logs()).contains("Plugin Foo [foo] is ignored because entry point class is not defined"); } + @Test + public void fail_when_views_is_installed() throws Exception { + copyTestPluginTo("fake-views-plugin", fs.getInstalledPluginsDir()); + + thrown.expect(MessageException.class); + thrown.expectMessage("Plugin 'views' is no more compatible with this version of SonarQube"); + underTest.start(); + } + + @Test + public void fail_when_sqale_plugin_is_installed() throws Exception { + copyTestPluginTo("fake-sqale-plugin", fs.getInstalledPluginsDir()); + + thrown.expect(MessageException.class); + thrown.expectMessage("Plugin 'sqale' is no more compatible with this version of SonarQube"); + underTest.start(); + } + + @Test + public void fail_when_report_is_installed() throws Exception { + copyTestPluginTo("fake-report-plugin", fs.getInstalledPluginsDir()); + + thrown.expect(MessageException.class); + thrown.expectMessage("Plugin 'report' is no more compatible with this version of SonarQube"); + underTest.start(); + } + /** * Some plugins can only extend the classloader of base plugin, without declaring new extensions. */ diff --git a/server/sonar-server/src/test/projects/fake-report-plugin/pom.xml b/server/sonar-server/src/test/projects/fake-report-plugin/pom.xml new file mode 100644 index 00000000000..72a04dbe04f --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-report-plugin/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + org.sonarsource.sonarqube.tests + fake-report-plugin + 0.1-SNAPSHOT + sonar-plugin + Fake Report Plugin + Fake Report Plugin + + + + org.codehaus.sonar + sonar-plugin-api + 4.5.4 + provided + + + + src + + + org.sonarsource.sonar-packaging-maven-plugin + sonar-packaging-maven-plugin + 1.15 + true + + report + BasePlugin + + + + + + diff --git a/server/sonar-server/src/test/projects/fake-report-plugin/src/BasePlugin.java b/server/sonar-server/src/test/projects/fake-report-plugin/src/BasePlugin.java new file mode 100644 index 00000000000..57b4a5dfb98 --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-report-plugin/src/BasePlugin.java @@ -0,0 +1,11 @@ +import org.sonar.api.SonarPlugin; + +import java.util.Collections; +import java.util.List; + +public class BasePlugin extends SonarPlugin { + + public List getExtensions() { + return Collections.emptyList(); + } +} diff --git a/server/sonar-server/src/test/projects/fake-report-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java b/server/sonar-server/src/test/projects/fake-report-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java new file mode 100644 index 00000000000..356a9c829af --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-report-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java @@ -0,0 +1,6 @@ +package org.sonar.plugins.testbase.api; + +public class BaseApi { + public void doNothing() { + } +} diff --git a/server/sonar-server/src/test/projects/fake-report-plugin/target/fake-report-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/fake-report-plugin/target/fake-report-plugin-0.1-SNAPSHOT.jar new file mode 100644 index 00000000000..6085e44fdca Binary files /dev/null and b/server/sonar-server/src/test/projects/fake-report-plugin/target/fake-report-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/fake-sqale-plugin/pom.xml b/server/sonar-server/src/test/projects/fake-sqale-plugin/pom.xml new file mode 100644 index 00000000000..e417dd96fba --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-sqale-plugin/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + org.sonarsource.sonarqube.tests + fake-sqale-plugin + 0.1-SNAPSHOT + sonar-plugin + Fake SQALE Plugin + Fake SQALE Plugin + + + + org.codehaus.sonar + sonar-plugin-api + 4.5.4 + provided + + + + src + + + org.sonarsource.sonar-packaging-maven-plugin + sonar-packaging-maven-plugin + 1.15 + true + + sqale + BasePlugin + + + + + + diff --git a/server/sonar-server/src/test/projects/fake-sqale-plugin/src/BasePlugin.java b/server/sonar-server/src/test/projects/fake-sqale-plugin/src/BasePlugin.java new file mode 100644 index 00000000000..57b4a5dfb98 --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-sqale-plugin/src/BasePlugin.java @@ -0,0 +1,11 @@ +import org.sonar.api.SonarPlugin; + +import java.util.Collections; +import java.util.List; + +public class BasePlugin extends SonarPlugin { + + public List getExtensions() { + return Collections.emptyList(); + } +} diff --git a/server/sonar-server/src/test/projects/fake-sqale-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java b/server/sonar-server/src/test/projects/fake-sqale-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java new file mode 100644 index 00000000000..356a9c829af --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-sqale-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java @@ -0,0 +1,6 @@ +package org.sonar.plugins.testbase.api; + +public class BaseApi { + public void doNothing() { + } +} diff --git a/server/sonar-server/src/test/projects/fake-sqale-plugin/target/fake-sqale-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/fake-sqale-plugin/target/fake-sqale-plugin-0.1-SNAPSHOT.jar new file mode 100644 index 00000000000..b5c99f721b3 Binary files /dev/null and b/server/sonar-server/src/test/projects/fake-sqale-plugin/target/fake-sqale-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/fake-views-plugin/pom.xml b/server/sonar-server/src/test/projects/fake-views-plugin/pom.xml new file mode 100644 index 00000000000..1ef73d2ffda --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-views-plugin/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + org.sonarsource.sonarqube.tests + fake-views-plugin + 0.1-SNAPSHOT + sonar-plugin + Fake Views Plugin + Fake Views Plugin + + + + org.codehaus.sonar + sonar-plugin-api + 4.5.4 + provided + + + + src + + + org.sonarsource.sonar-packaging-maven-plugin + sonar-packaging-maven-plugin + 1.15 + true + + views + BasePlugin + + + + + + diff --git a/server/sonar-server/src/test/projects/fake-views-plugin/src/BasePlugin.java b/server/sonar-server/src/test/projects/fake-views-plugin/src/BasePlugin.java new file mode 100644 index 00000000000..1fc5b5496ba --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-views-plugin/src/BasePlugin.java @@ -0,0 +1,31 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import org.sonar.api.SonarPlugin; + +import java.util.Collections; +import java.util.List; + +public class BasePlugin extends SonarPlugin { + + public List getExtensions() { + return Collections.emptyList(); + } +} diff --git a/server/sonar-server/src/test/projects/fake-views-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java b/server/sonar-server/src/test/projects/fake-views-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java new file mode 100644 index 00000000000..356a9c829af --- /dev/null +++ b/server/sonar-server/src/test/projects/fake-views-plugin/src/org/sonar/plugins/testbase/api/BaseApi.java @@ -0,0 +1,6 @@ +package org.sonar.plugins.testbase.api; + +public class BaseApi { + public void doNothing() { + } +} diff --git a/server/sonar-server/src/test/projects/fake-views-plugin/target/fake-views-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/fake-views-plugin/target/fake-views-plugin-0.1-SNAPSHOT.jar new file mode 100644 index 00000000000..a47d93d94a8 Binary files /dev/null and b/server/sonar-server/src/test/projects/fake-views-plugin/target/fake-views-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/pom.xml b/server/sonar-server/src/test/projects/pom.xml index 2ae2bb8b9ec..37338313ac0 100644 --- a/server/sonar-server/src/test/projects/pom.xml +++ b/server/sonar-server/src/test/projects/pom.xml @@ -14,6 +14,9 @@ test-libs-plugin test-require-plugin test-requirenew-plugin + fake-report-plugin + fake-sqale-plugin + fake-views-plugin diff --git a/server/sonar-server/src/test/projects/test-base-plugin-v2/target/test-base-plugin-0.2-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-base-plugin-v2/target/test-base-plugin-0.2-SNAPSHOT.jar index 32ac594aad1..1d4ef5430c7 100644 Binary files a/server/sonar-server/src/test/projects/test-base-plugin-v2/target/test-base-plugin-0.2-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-base-plugin-v2/target/test-base-plugin-0.2-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-base-plugin/target/test-base-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-base-plugin/target/test-base-plugin-0.1-SNAPSHOT.jar index f943a16b28f..739a22fcdae 100644 Binary files a/server/sonar-server/src/test/projects/test-base-plugin/target/test-base-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-base-plugin/target/test-base-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-core-plugin/target/test-core-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-core-plugin/target/test-core-plugin-0.1-SNAPSHOT.jar index 278b4596227..831cc364b5c 100644 Binary files a/server/sonar-server/src/test/projects/test-core-plugin/target/test-core-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-core-plugin/target/test-core-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-extend-plugin/target/test-extend-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-extend-plugin/target/test-extend-plugin-0.1-SNAPSHOT.jar index 71dcee70496..2f63c2e652c 100644 Binary files a/server/sonar-server/src/test/projects/test-extend-plugin/target/test-extend-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-extend-plugin/target/test-extend-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-libs-plugin/target/test-libs-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-libs-plugin/target/test-libs-plugin-0.1-SNAPSHOT.jar index 590d91b74f2..6ebe8652d8b 100644 Binary files a/server/sonar-server/src/test/projects/test-libs-plugin/target/test-libs-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-libs-plugin/target/test-libs-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-require-plugin/target/test-require-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-require-plugin/target/test-require-plugin-0.1-SNAPSHOT.jar index abf9bbed5eb..f5fc95f9d0d 100644 Binary files a/server/sonar-server/src/test/projects/test-require-plugin/target/test-require-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-require-plugin/target/test-require-plugin-0.1-SNAPSHOT.jar differ diff --git a/server/sonar-server/src/test/projects/test-requirenew-plugin/target/test-requirenew-plugin-0.1-SNAPSHOT.jar b/server/sonar-server/src/test/projects/test-requirenew-plugin/target/test-requirenew-plugin-0.1-SNAPSHOT.jar index 671f69f10f8..0dd577fc360 100644 Binary files a/server/sonar-server/src/test/projects/test-requirenew-plugin/target/test-requirenew-plugin-0.1-SNAPSHOT.jar and b/server/sonar-server/src/test/projects/test-requirenew-plugin/target/test-requirenew-plugin-0.1-SNAPSHOT.jar differ