13d1abf01e
Upstream has released updates that appears to apply and compile correctly. This update has only been PARTIALLY tested by PaperMC and as with ANY update, please do your own testing I've tested basic region file saving as well as our oversized chunks approach. Bukkit Changes: e167e549 Clarify MerchantInventory#getSelectedRecipe. 3a1d5b8f Apply default permissions by registration order. c64cc93f Make tags Keyed ec037ed7 Added a method to get a list of tags bfb6ef86 Introduce rotation methods to the Vector class fc727372 Remove draft API from FluidLevelChangeEvent CraftBukkit Changes:6430d9c0
SPIGOT-4632: BlockState location is not fixed14cd1688
Fix CraftInventoryMerchant#getSelectedRecipe if there is no active merchant recipe.c24abab7
Load custom permissions after default permissions.bc99dfe8
Make tags Keyed6fce004f
Added a method to get a list of tags Spigot Changes: e5e5c7c6 Allow Saving Large Chunks e8d3881c Rebuild patches
149 Zeilen
6.3 KiB
Diff
149 Zeilen
6.3 KiB
Diff
From 53b080c35566392e83fc231ce763897a0e9420a4 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 1 May 2018 21:33:35 -0400
|
|
Subject: [PATCH] Close Plugin Class Loaders on Disable
|
|
|
|
This should close more memory leaks from /reload and disabling plugins,
|
|
by closing the class loader and the jar file.
|
|
|
|
diff --git a/src/main/java/org/bukkit/plugin/PluginLoader.java b/src/main/java/org/bukkit/plugin/PluginLoader.java
|
|
index e7981a1d..d34756f1 100644
|
|
--- a/src/main/java/org/bukkit/plugin/PluginLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/PluginLoader.java
|
|
@@ -73,4 +73,19 @@ public interface PluginLoader {
|
|
* @param plugin Plugin to disable
|
|
*/
|
|
public void disablePlugin(Plugin plugin);
|
|
+
|
|
+ // Paper start - close Classloader on disable
|
|
+ /**
|
|
+ * Disables the specified plugin
|
|
+ * <p>
|
|
+ * Attempting to disable a plugin that is not enabled will have no effect
|
|
+ *
|
|
+ * @param plugin Plugin to disable
|
|
+ * @param closeClassloader if the classloader for the Plugin should be closed
|
|
+ */
|
|
+ // provide default to allow other PluginLoader implementations to work
|
|
+ default public void disablePlugin(Plugin plugin, boolean closeClassloader) {
|
|
+ disablePlugin(plugin);
|
|
+ }
|
|
+ // Paper end - close Classloader on disable
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/plugin/PluginManager.java b/src/main/java/org/bukkit/plugin/PluginManager.java
|
|
index e5638d56..b72d5a9b 100644
|
|
--- a/src/main/java/org/bukkit/plugin/PluginManager.java
|
|
+++ b/src/main/java/org/bukkit/plugin/PluginManager.java
|
|
@@ -154,6 +154,18 @@ public interface PluginManager {
|
|
*/
|
|
public void disablePlugin(Plugin plugin);
|
|
|
|
+ // Paper start - close Classloader on disable
|
|
+ /**
|
|
+ * Disables the specified plugin
|
|
+ * <p>
|
|
+ * Attempting to disable a plugin that is not enabled will have no effect
|
|
+ *
|
|
+ * @param plugin Plugin to disable
|
|
+ * @param closeClassloader if the classloader for the Plugin should be closed
|
|
+ */
|
|
+ public void disablePlugin(Plugin plugin, boolean closeClassloader);
|
|
+ // Paper end - close Classloader on disable
|
|
+
|
|
/**
|
|
* Gets a {@link Permission} from its fully qualified name
|
|
*
|
|
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
index 5034215a..d925423d 100644
|
|
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
|
@@ -413,17 +413,29 @@ public final class SimplePluginManager implements PluginManager {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - close Classloader on disable
|
|
public void disablePlugins() {
|
|
+ disablePlugins(false);
|
|
+ }
|
|
+
|
|
+ public void disablePlugins(boolean closeClassloaders) {
|
|
+ // Paper end - close Classloader on disable
|
|
Plugin[] plugins = getPlugins();
|
|
for (int i = plugins.length - 1; i >= 0; i--) {
|
|
- disablePlugin(plugins[i]);
|
|
+ disablePlugin(plugins[i], closeClassloaders); // Paper - close Classloader on disable
|
|
}
|
|
}
|
|
|
|
- public void disablePlugin(final Plugin plugin) {
|
|
+ // Paper start - close Classloader on disable
|
|
+ public void disablePlugin(Plugin plugin) {
|
|
+ disablePlugin(plugin, false);
|
|
+ }
|
|
+
|
|
+ public void disablePlugin(final Plugin plugin, boolean closeClassloader) {
|
|
+ // Paper end - close Classloader on disable
|
|
if (plugin.isEnabled()) {
|
|
try {
|
|
- plugin.getPluginLoader().disablePlugin(plugin);
|
|
+ plugin.getPluginLoader().disablePlugin(plugin, closeClassloader); // Paper - close Classloader on disable
|
|
} catch (Throwable ex) {
|
|
handlePluginException("Error occurred (in the plugin loader) while disabling "
|
|
+ plugin.getDescription().getFullName() + " (Is it up to date?)", ex, plugin); // Paper
|
|
@@ -469,7 +481,7 @@ public final class SimplePluginManager implements PluginManager {
|
|
|
|
public void clearPlugins() {
|
|
synchronized (this) {
|
|
- disablePlugins();
|
|
+ disablePlugins(true); // Paper - close Classloader on disable
|
|
plugins.clear();
|
|
lookupNames.clear();
|
|
HandlerList.unregisterAll();
|
|
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
index 77207f14..c7782e7d 100644
|
|
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
|
@@ -320,7 +320,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
} catch (Throwable ex) {
|
|
server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
|
// Paper start - Disable plugins that fail to load
|
|
- disablePlugin(jPlugin);
|
|
+ server.getPluginManager().disablePlugin(jPlugin, true); // Paper - close Classloader on disable - She's dead jim
|
|
return;
|
|
// Paper end
|
|
}
|
|
@@ -331,7 +331,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
}
|
|
}
|
|
|
|
+ // Paper start - close Classloader on disable
|
|
public void disablePlugin(Plugin plugin) {
|
|
+ disablePlugin(plugin, false); // Retain old behavior unless requested
|
|
+ }
|
|
+
|
|
+ public void disablePlugin(Plugin plugin, boolean closeClassloader) {
|
|
+ // Paper end - close Class Loader on disable
|
|
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
|
|
|
|
if (plugin.isEnabled()) {
|
|
@@ -358,6 +364,16 @@ public final class JavaPluginLoader implements PluginLoader {
|
|
for (String name : names) {
|
|
removeClass(name);
|
|
}
|
|
+ // Paper start - close Class Loader on disable
|
|
+ try {
|
|
+ if (closeClassloader) {
|
|
+ loader.close();
|
|
+ }
|
|
+ } catch (IOException e) {
|
|
+ server.getLogger().log(Level.WARNING, "Error closing the Plugin Class Loader for " + plugin.getDescription().getFullName());
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.20.1
|
|
|