Skip to content

Commit 1f044f0

Browse files
committed
Fixed Plugin Repos
1 parent e233b35 commit 1f044f0

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

core/src/main/java/org/correomqtt/core/plugin/PluginManager.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.net.MalformedURLException;
3838
import java.net.URL;
3939
import java.nio.file.Path;
40-
import java.sql.Array;
4140
import java.util.ArrayList;
4241
import java.util.Collection;
4342
import java.util.Collections;
@@ -111,16 +110,20 @@ public BundledPluginList.BundledPlugins getBundledPlugins() {
111110
try {
112111
LOGGER.info("Read bundled plugins '{}'", bundledPluginUrl);
113112
BundledPluginList bundledPluginList = new ObjectMapper().readValue(new URL(bundledPluginUrl), BundledPluginList.class);
114-
String version = VersionUtils.getVersion().trim();
115-
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(version);
113+
String versionSharp = VersionUtils.getVersion();
114+
String versionUnsharp = VersionUtils.getMajorMinorPatch(versionSharp);
115+
BundledPluginList.BundledPlugins bundledPluginsByVersion = bundledPluginList.getVersions().get(versionSharp);
116+
if(bundledPluginsByVersion == null) {
117+
bundledPluginsByVersion = bundledPluginList.getVersions().get(versionUnsharp);
118+
}
116119
if (bundledPluginsByVersion == null) {
117-
LOGGER.warn("No bundled plugins found for version '{}'", version);
120+
LOGGER.warn("No bundled plugins found for version '{}'", versionSharp);
118121
bundledPlugins = BundledPluginList.BundledPlugins.builder().build();
119122
} else {
120123
LOGGER.info("Found {} bundled plugins and {} plugins to be removed for version '{}'.",
121124
bundledPluginsByVersion.getInstall().size(),
122125
bundledPluginsByVersion.getUninstall().size(),
123-
version);
126+
versionSharp);
124127
bundledPlugins = bundledPluginsByVersion;
125128
}
126129
return bundledPluginsByVersion;

core/src/main/java/org/correomqtt/core/utils/VersionUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class VersionUtils {
2828

2929
private static final Pattern MAJOR_MINOR_PATTERN = Pattern.compile("^([0-9]+).([0-9]+)");
3030

31+
private static final Pattern MAJOR_MINOR_PATCH_PATTERN = Pattern.compile("^([0-9]+).([0-9]+).([0-9]+)");
32+
3133
private VersionUtils() {
3234
// private constructor
3335
}
@@ -90,4 +92,13 @@ public static String getMajorMinor(String version) {
9092
}
9193
return "invalid";
9294
}
95+
96+
97+
public static String getMajorMinorPatch(String version) {
98+
Matcher matcher = MAJOR_MINOR_PATCH_PATTERN.matcher(version);
99+
if (matcher.find() && matcher.groupCount() > 1) {
100+
return matcher.group(0);
101+
}
102+
return "invalid";
103+
}
93104
}

gui/src/main/java/org/correomqtt/gui/plugin/PluginLauncher.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ private int installBundledPlugins(UpdateManager updateManager,
7070
PluginManager pluginManager,
7171
BundledPluginList.BundledPlugins bundledPlugins) {
7272
int installedPlugins = 0;
73+
if(bundledPlugins == null){
74+
return installedPlugins;
75+
}
7376
for (String pluginId : bundledPlugins.getInstall()) {
7477
// Already installed?
7578
if (pluginManager.getPlugin(pluginId) != null) {

0 commit comments

Comments
 (0)