diff --git a/core/src/main/java/org/correomqtt/core/plugin/PluginManager.java b/core/src/main/java/org/correomqtt/core/plugin/PluginManager.java index dfb97f4f9..539b02d61 100644 --- a/core/src/main/java/org/correomqtt/core/plugin/PluginManager.java +++ b/core/src/main/java/org/correomqtt/core/plugin/PluginManager.java @@ -37,7 +37,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Path; -import java.sql.Array; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -111,16 +110,20 @@ public BundledPluginList.BundledPlugins getBundledPlugins() { try { LOGGER.info("Read bundled plugins '{}'", bundledPluginUrl); BundledPluginList bundledPluginList = new ObjectMapper().readValue(new URL(bundledPluginUrl), BundledPluginList.class); - String version = VersionUtils.getVersion().trim(); - BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(version); + String versionSharp = VersionUtils.getVersion(); + String versionUnsharp = VersionUtils.getMajorMinorPatch(versionSharp); + BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(versionSharp); + if(bundledPluginsByVersion == null) { + bundledPluginsByVersion = bundledPluginList.getVersions().get(versionUnsharp); + } if (bundledPluginsByVersion == null) { - LOGGER.warn("No bundled plugins found for version '{}'", version); + LOGGER.warn("No bundled plugins found for version '{}'", versionSharp); bundledPlugins = BundledPluginList.BundledPlugins.builder().build(); } else { LOGGER.info("Found {} bundled plugins and {} plugins to be removed for version '{}'.", bundledPluginsByVersion.getInstall().size(), bundledPluginsByVersion.getUninstall().size(), - version); + versionSharp); bundledPlugins = bundledPluginsByVersion; } return bundledPluginsByVersion; diff --git a/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java b/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java index 02ceee3d4..de6090547 100644 --- a/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java +++ b/core/src/main/java/org/correomqtt/core/utils/VersionUtils.java @@ -28,6 +28,8 @@ public class VersionUtils { private static final Pattern MAJOR_MINOR_PATTERN = Pattern.compile("^([0-9]+).([0-9]+)"); + private static final Pattern MAJOR_MINOR_PATCH_PATTERN = Pattern.compile("^([0-9]+).([0-9]+).([0-9]+)"); + private VersionUtils() { // private constructor } @@ -90,4 +92,13 @@ public static String getMajorMinor(String version) { } return "invalid"; } + + + public static String getMajorMinorPatch(String version) { + Matcher matcher = MAJOR_MINOR_PATCH_PATTERN.matcher(version); + if (matcher.find() && matcher.groupCount() > 1) { + return matcher.group(0); + } + return "invalid"; + } } diff --git a/gui/src/main/java/org/correomqtt/gui/plugin/PluginLauncher.java b/gui/src/main/java/org/correomqtt/gui/plugin/PluginLauncher.java index a48f570a1..0b5cac206 100644 --- a/gui/src/main/java/org/correomqtt/gui/plugin/PluginLauncher.java +++ b/gui/src/main/java/org/correomqtt/gui/plugin/PluginLauncher.java @@ -70,6 +70,9 @@ private int installBundledPlugins(UpdateManager updateManager, PluginManager pluginManager, BundledPluginList.BundledPlugins bundledPlugins) { int installedPlugins = 0; + if(bundledPlugins == null){ + return installedPlugins; + } for (String pluginId : bundledPlugins.getInstall()) { // Already installed? if (pluginManager.getPlugin(pluginId) != null) {