Open CC007 opened 5 years ago
My guess is that the classloader is not properly restored at the onDisable
hook, my test plugins works fine with:
@Override
public void onDisable() {
try {
if (context != null) {
context.close();
}
} finally {
context = null;
Thread.currentThread().setContextClassLoader(defaultClassLoader);
}
}
Can you verify this?
If this is not the case, you can also restore the default classloader right after the application startup:
@Override
public void onEnable() {
try {
// app startup
} finally {
Thread.currentThread().setContextClassLoader(defaultClassLoader);
}
}
The bukkit plugin reloading system is a mystery, so it's hard to deduce the problem.
My code looks the same, except for the try/finally usage, but that should only matter if an exception is actually thrown durind the on disable.
The only difference is that I change the class loader before starting the spring application, because it needs to be set before feign is initialized
I still don't know what the cause of this problem, maybe something caused by the classloader, but no clue about exactly what it is. Can you reproduce the problem without the feign client?
I'll try that once I have time
Have you tried look into certain beans that get their close
or destroy
method automatically called when destroyed? If this happens to bukkit, of course it would close the server.
Can you reproduce this bug in the latest version with SpringSpigotBootstrapper
? (0.20.7)
It now starts the spring context in a different thread, without having to change the context class loader of the main one, this can solve other problems too.
I might have accidentally fixed this by using a compound classloader. I need to test this a bit further, because there are other issues during the restart (my database lockfile is causing problems, see CC007/HeadsPluginAPI#8). If I'm still experiencing issues with restart after fixing those, I'll give the SpringSpigotBootstrapper a try.
When I start the server, the plugin loads fine (now that the classloaders and shading is fixed), but when using
/reload
I get the following exceptions: