mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-27 23:55:36 +00:00
Properly cleanup JarInJarClassLoader when plugin disables
This commit is contained in:
4 files changed
+34
-1
No files matched your search
@@ -255,6 +255,9 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
// shutdown async executor pool
|
||||
getBootstrap().getScheduler().shutdownExecutor();
|
||||
|
||||
// close classpath appender
|
||||
getBootstrap().getClassPathAppender().close();
|
||||
|
||||
getLogger().info("Goodbye!");
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -30,8 +30,12 @@ import java.nio.file.Path;
|
||||
/**
|
||||
* Interface which allows access to add URLs to the plugin classpath at runtime.
|
||||
*/
|
||||
public interface ClassPathAppender {
|
||||
public interface ClassPathAppender extends AutoCloseable {
|
||||
|
||||
void addJarToClasspath(Path file);
|
||||
|
||||
@Override
|
||||
default void close() {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -27,6 +27,7 @@ package me.lucko.luckperms.common.plugin.classpath;
|
||||
|
||||
import me.lucko.luckperms.common.loader.JarInJarClassLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@@ -48,4 +49,14 @@ public class JarInJarClassPathAppender implements ClassPathAppender {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
this.classLoader.deleteJarResource();
|
||||
try {
|
||||
this.classLoader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user