Close plugin jar file on classloader close and after retrieving name for updating (#8902)
Dieser Commit ist enthalten in:
Ursprung
4ae202eb82
Commit
b670798876
@ -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;
|
||||
|
||||
|
@ -93,7 +93,7 @@ index 71c8d2345eef6895edb8d210553ec3cddd9c76d0..6d31f3a2569ae9c522a5e6cddd38ac8f
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index dd569f2fc6098650d202e834b343b1bff2d42284..fade45ef475ae20922f5abea49a0f035d19b7819 100644
|
||||
index c42663a2ae98fda6dcf2ab6ac899cc6238bce65f..ed2492ce51097dd0c2ba72e7b9449561a73ea7e3 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -64,7 +64,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
|
@ -5,15 +5,15 @@ Subject: [PATCH] Enable multi-release plugin jars
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index fade45ef475ae20922f5abea49a0f035d19b7819..264d712d3399d24cb01b85fc2d055d9fbf11b23a 100644
|
||||
index ed2492ce51097dd0c2ba72e7b9449561a73ea7e3..9c409dcd0179bea236311e1d5998daa4245e1542 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -59,7 +59,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
this.description = description;
|
||||
this.dataFolder = dataFolder;
|
||||
this.file = file;
|
||||
- this.jar = new JarFile(file);
|
||||
+ this.jar = new JarFile(file, true, java.util.zip.ZipFile.OPEN_READ, JarFile.runtimeVersion()); // Paper - enable multi-release jars for Java 9+
|
||||
- this.jar = jarFile == null ? new JarFile(file) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider
|
||||
+ this.jar = jarFile == null ? new JarFile(file, true, java.util.zip.ZipFile.OPEN_READ, JarFile.runtimeVersion()) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider // Paper - enable multi-release jars for Java 9+
|
||||
this.manifest = jar.getManifest();
|
||||
this.url = file.toURI().toURL();
|
||||
this.libraryLoader = libraryLoader;
|
||||
|
@ -5,13 +5,13 @@ Subject: [PATCH] Rewrite LogEvents to contain the source jars in stack traces
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 264d712d3399d24cb01b85fc2d055d9fbf11b23a..327ff03fa1978881fa6f6ba20e33e3c049c2e3cd 100644
|
||||
index 9c409dcd0179bea236311e1d5998daa4245e1542..bfc4a97f1fb0d245056598d5211ff2347a431b64 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -53,7 +53,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
|
||||
@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);
|
||||
+ super(file.getName(), new URL[] {file.toURI().toURL()}, parent);
|
||||
this.loader = null; // Paper - pass null into loader field
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Also load resources from LibraryLoader
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 327ff03fa1978881fa6f6ba20e33e3c049c2e3cd..7d300a539ac2ef1c773cfa90cecc8655490a8686 100644
|
||||
index bfc4a97f1fb0d245056598d5211ff2347a431b64..e89ab347b908cc92274dd5dd796a02249f899977 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -93,14 +93,35 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
|
@ -803,10 +803,10 @@ index 0000000000000000000000000000000000000000..f9a2c55a354c877749db3f92956de802
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..392eb260b44d5f9e685ce09596c19f0af9cc0339
|
||||
index 0000000000000000000000000000000000000000..79581d917e754998123b94b9f4ea7d1e78f017ae
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
@@ -0,0 +1,204 @@
|
||||
@@ -0,0 +1,202 @@
|
||||
+package io.papermc.paper.plugin.entrypoint.classloader;
|
||||
+
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
@ -1004,10 +1004,8 @@ index 0000000000000000000000000000000000000000..392eb260b44d5f9e685ce09596c19f0a
|
||||
+
|
||||
+ @Override
|
||||
+ public void close() throws IOException {
|
||||
+ try {
|
||||
+ try (this.jar; this.libraryLoader) {
|
||||
+ super.close();
|
||||
+ } finally {
|
||||
+ this.libraryLoader.close();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
@ -4985,10 +4983,10 @@ index 0000000000000000000000000000000000000000..1822e076601db51c8a7954036853bee1
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e6a99f422038fad519215abf239135b11edc2bce
|
||||
index 0000000000000000000000000000000000000000..0077a0a82c04bae0d93ab5c9cf07364b7c947bb3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
|
||||
@@ -0,0 +1,156 @@
|
||||
@@ -0,0 +1,157 @@
|
||||
+package io.papermc.paper.plugin.provider.source;
|
||||
+
|
||||
+import io.papermc.paper.plugin.PluginInitializerManager;
|
||||
@ -5089,7 +5087,7 @@ index 0000000000000000000000000000000000000000..e6a99f422038fad519215abf239135b1
|
||||
+ }
|
||||
+
|
||||
+ private String getPluginName(Path path) throws Exception {
|
||||
+ JarFile file = new JarFile(path.toFile());
|
||||
+ try (JarFile file = new JarFile(path.toFile())) {
|
||||
+ PluginFileType<?, ?> type = PluginFileType.guessType(file);
|
||||
+ if (type == null) {
|
||||
+ throw new IllegalArgumentException(path + " is not a valid plugin file, cannot load a plugin from it!");
|
||||
@ -5097,6 +5095,7 @@ index 0000000000000000000000000000000000000000..e6a99f422038fad519215abf239135b1
|
||||
+
|
||||
+ return type.getConfig(file).getName();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private class UpdateFileVisitor implements FileVisitor<Path> {
|
||||
+
|
||||
@ -5819,7 +5818,7 @@ index 0000000000000000000000000000000000000000..b2a6544e321fa61c58bdf5684231de10
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9a19abaccec91df9b2614dd6638d7bc199bdac2c
|
||||
index 0000000000000000000000000000000000000000..c074e8651528a19a4485fb7e9d56c649ba704ca4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProvider.java
|
||||
@@ -0,0 +1,190 @@
|
||||
@ -5944,7 +5943,7 @@ index 0000000000000000000000000000000000000000..9a19abaccec91df9b2614dd6638d7bc1
|
||||
+
|
||||
+ final PluginClassLoader loader;
|
||||
+ try {
|
||||
+ loader = new PluginClassLoader(this.getClass().getClassLoader(), this.description, dataFolder, this.path.toFile(), LIBRARY_LOADER.createLoader(this.description)); // Paper
|
||||
+ loader = new PluginClassLoader(this.getClass().getClassLoader(), this.description, dataFolder, this.path.toFile(), LIBRARY_LOADER.createLoader(this.description), this.jarFile); // Paper
|
||||
+ } catch (InvalidPluginException ex) {
|
||||
+ throw ex;
|
||||
+ } catch (Throwable ex) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren