Close plugin jar file on classloader close and after retrieving name for updating (#8902)
This commit is contained in:
parent
4ae202eb82
commit
b670798876
6 changed files with 29 additions and 28 deletions
|
@ -1969,7 +1969,7 @@ index 669a70faa95d0d6525a731d73499ed6fb0b48320..c9cf9d361a1289aba383718733a2098b
|
|||
throw new IllegalStateException("Cannot get plugin for " + clazz + " from a static initializer");
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index 047c0304fd617cec990f80815b43916c6ef5a94c..fa39c93d76ebb9eecce1f4b5203cb361e4778b4f 100644
|
||||
index 047c0304fd617cec990f80815b43916c6ef5a94c..d0ad072c832b8fc8a1cfdcafdd42c724531a2e29 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -49,6 +49,7 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
@ -1993,7 +1993,7 @@ index 047c0304fd617cec990f80815b43916c6ef5a94c..fa39c93d76ebb9eecce1f4b5203cb361
|
|||
final PluginClassLoader loader;
|
||||
try {
|
||||
- loader = new PluginClassLoader(this, getClass().getClassLoader(), description, dataFolder, file, (libraryLoader != null) ? libraryLoader.createLoader(description) : null);
|
||||
+ loader = new PluginClassLoader(getClass().getClassLoader(), description, dataFolder, file, (libraryLoader != null) ? libraryLoader.createLoader(description) : null); // Paper
|
||||
+ loader = new PluginClassLoader(getClass().getClassLoader(), description, dataFolder, file, (libraryLoader != null) ? libraryLoader.createLoader(description) : null, null); // Paper
|
||||
} catch (InvalidPluginException ex) {
|
||||
throw ex;
|
||||
} catch (Throwable ex) {
|
||||
|
@ -2014,7 +2014,7 @@ index 6d634b0ea813ccb19f1562a7d0e5a59cea4eab21..f9e67e20133d349e43d126dbb48b34d4
|
|||
|
||||
private final Logger logger;
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 2f74ec96ece706de23156ebabfe493211bc05391..dd569f2fc6098650d202e834b343b1bff2d42284 100644
|
||||
index 2f74ec96ece706de23156ebabfe493211bc05391..c42663a2ae98fda6dcf2ab6ac899cc6238bce65f 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -29,7 +29,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
@ -2027,7 +2027,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..dd569f2fc6098650d202e834b343b1bf
|
|||
private final JavaPluginLoader loader;
|
||||
private final Map<String, Class<?>> classes = new ConcurrentHashMap<String, Class<?>>();
|
||||
private final PluginDescriptionFile description;
|
||||
@@ -43,16 +44,18 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
@@ -43,24 +44,30 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
private JavaPlugin pluginInit;
|
||||
private IllegalStateException pluginState;
|
||||
private final Set<String> seenIllegalAccess = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
@ -2040,7 +2040,7 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..dd569f2fc6098650d202e834b343b1bf
|
|||
|
||||
- PluginClassLoader(@NotNull final JavaPluginLoader loader, @Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException {
|
||||
+ @org.jetbrains.annotations.ApiStatus.Internal // Paper
|
||||
+ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException { // Paper
|
||||
+ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, @Nullable JarFile jarFile) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider
|
||||
super(new URL[] {file.toURI().toURL()}, parent);
|
||||
- Preconditions.checkArgument(loader != null, "Loader cannot be null");
|
||||
+ this.loader = null; // Paper - pass null into loader field
|
||||
|
@ -2049,7 +2049,9 @@ index 2f74ec96ece706de23156ebabfe493211bc05391..dd569f2fc6098650d202e834b343b1bf
|
|||
this.description = description;
|
||||
this.dataFolder = dataFolder;
|
||||
this.file = file;
|
||||
@@ -61,6 +64,10 @@ final class PluginClassLoader extends URLClassLoader {
|
||||
- this.jar = new JarFile(file);
|
||||
+ this.jar = jarFile == null ? new JarFile(file) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider
|
||||
this.manifest = jar.getManifest();
|
||||
this.url = file.toURI().toURL();
|
||||
this.libraryLoader = libraryLoader;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue