FrankHeijden/ServerUtils

Service loader no longer working after disabling plugin

Elikill58 opened this issue · 7 comments

I'm a developer of a plugin that use ServiceLoader.load() method.

When I start the server, everything works fine. But after disabling then enabling again, nothing is working properly: services doesn't find any thing.

hey, could you cook up a minimal reproducible example plugin?

Sure, I will do.

Update: sorry for the time, but I finally made a quick plugin.
You can check code here: https://github.com/Elikill58/ServerUtilsTest
There is a github action to download it (and with gradle, you can run it yourself)

Update: sorry for the time, but I finally made a quick plugin.

Lol you actually made it quite quickly for a sunday 😄 I was first testing the reloading process with ServerUtils, and tried adding and removing an example service to see how that affects the process. They all succeeded:
Screenshot 2022-07-18 at 14 36 28

The issue here is disabling/enabling, a feature only the bukkit version has of ServerUtils which is inherently broken; the ClassLoader of the plugin gets closed when performing the action, creating a situation where a disabled plugin cannot be enabled again. I am looking to remove the disabling/enabling feature in the future from ServerUtils, in favour of the other options.

Hi, ok so it's fine. But you tried by editing complete jar ? the su rp <plugin> works even if we change it ? wow, I will check it. But you can't try to restart the ClassLoader ?

m well not really, its easier to just boot up a new one with a new instance in that case (which is what reloadplugin/rp does with a full reload cycle)

I just tested, and yes with su rp it works :) and ok x)