aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Niang <johnniang@foxmail.com>2024-04-06 22:25:21 +0800
committerGitHub <noreply@github.com>2024-04-06 17:25:21 +0300
commitf563b9168b4beaca95b28541c1031b0dd7bed913 (patch)
treeaf295f468480e4b62fe8e69fdf5d58a3a0c4943a
parent36c036f79ece484cbf5f6861a86d071e54644175 (diff)
downloadpf4j-f563b9168b4beaca95b28541c1031b0dd7bed913.tar.gz
pf4j-f563b9168b4beaca95b28541c1031b0dd7bed913.zip
Fix the problem of not being able to disable plugins correctly (#577)
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java2
-rw-r--r--pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java13
2 files changed, 14 insertions, 1 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
index 78c261c..559fc81 100644
--- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
@@ -537,7 +537,7 @@ public abstract class AbstractPluginManager implements PluginManager {
log.debug("Already disabled plugin '{}'", getPluginLabel(pluginDescriptor));
return true;
} else if (PluginState.STARTED == pluginState) {
- if (PluginState.STOPPED == stopPlugin(pluginId)) {
+ if (PluginState.STOPPED != stopPlugin(pluginId)) {
log.error("Failed to stop plugin '{}' on disable", getPluginLabel(pluginDescriptor));
return false;
}
diff --git a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
index d95a2d0..bc23630 100644
--- a/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
+++ b/pf4j/src/test/java/org/pf4j/DefaultPluginManagerTest.java
@@ -167,6 +167,19 @@ public class DefaultPluginManagerTest {
}
@Test
+ void shouldDisablePluginAfterStarting() throws IOException {
+ new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
+ .pluginVersion("1.2.3")
+ .build();
+
+ pluginManager.loadPlugins();
+ pluginManager.startPlugins();
+ assertEquals(PluginState.STARTED, pluginManager.getPlugin("myPlugin").getPluginState());
+ pluginManager.disablePlugin("myPlugin");
+ assertEquals(PluginState.DISABLED, pluginManager.getPlugin("myPlugin").getPluginState());
+ }
+
+ @Test
public void deleteZipPlugin() throws Exception {
PluginZip pluginZip = new PluginZip.Builder(pluginsPath.resolve("my-plugin-1.2.3.zip"), "myPlugin")
.pluginVersion("1.2.3")