From 292a767d4aab4ef6aad38bf9fbb3762bbe569d58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 3 Aug 2018 13:59:32 +0200 Subject: [PATCH] SONAR-11083 fail at startup if License plugin < 3.4 is installed --- .../server/plugins/ServerPluginRepository.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 7fb654172f9..ff2675084b3 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 @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.io.FileUtils; import org.picocontainer.Startable; import org.sonar.api.Plugin; @@ -295,7 +296,19 @@ public class ServerPluginRepository implements PluginRepository, Startable { List orderedPlugins = Ordering.natural().sortedCopy(pluginInfosByKeys.values()); for (PluginInfo plugin : orderedPlugins) { LOG.info("Deploy plugin {}", SLASH_JOINER.join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild())); + if (plugin.getKey().equals("license") && isBefore34(plugin.getVersion())) { + throw MessageException.of("Your commercial edition is obsolete. You must upgrade the edition bundle to its latest version."); + } + } + } + + private static final Set BEFORE_4_MINOR_VERSION = ImmutableSet.of("0", "1", "2", "3"); + + private static boolean isBefore34(@Nullable Version version) { + if (version == null) { + return true; } + return "3".equals(version.getMajor()) && BEFORE_4_MINOR_VERSION.contains(version.getMinor()); } private void loadInstances() { -- 2.39.5