EssentialsX

EssentialsX

2M Downloads

Possible IllegalStateException with reason "zip file closed" on shutdown

Andre601 opened this issue ยท 5 comments

commented

Type of bug

Error in console

/ess dump all output

https://essentialsx.net/dump.html?id=786115a253c844309e01df330285523f

Error log (if applicable)

https://paste.gg/p/anonymous/daacac3d52f8477d90655d33a5a2a4f8

Bug description

When the Discord module gets disabled is there a chance of an IllegalStateException: zip file closed to be thrown.

This is due to some Bukkit-related behaviour and due to using JDA#shutdown() which isn't thread blocking (Therefore the plugin could be disabled/unloaded before JDA had the chance to fully shut down).

A fix for this is to JDA#shutdownNow() in onDisable() and put the thread to sleep until JDA completely shut down.

Steps to reproduce

  1. Shut down the Server while using the Discord module.
  2. That's it! (It's a bit random tho)

Expected behaviour

The Discord module should shutdown JDA properly.

Actual behaviour

An IllegalStateException is thrown with reason zip file closed

commented

This would be an issue with discord-webhooks. They don't provide a way to blocking shutdown.

commented

Not sure if it really is tho... Like as much as I understand the logic you provided on the Discord server, there is always the level of unpredictability that comes with Java... Especially on a Spigot/Paper server. Like I saw it so many times how some exception happened that by logic shouldn't happen at all...

You never know is what I want to say.

commented

Not sure if it really is tho... Like as much as I understand the logic you provided on the Discord server, there is always the level of unpredictability that comes with Java... Especially on a Spigot/Paper server. Like I saw it so many times how some exception happened that by logic shouldn't happen at all...

You never know is what I want to say.

I block the thread in onDisable while waiting for JDA to shutdown; Bukkit won't throwaway the plugin until the onDisable finishes. The way JDA shuts down, it's literally impossible for there to still be outstanding requests. Additionally, if I were to use shutdownNow, it wouldn't be a graceful shutdown as future requests are blocked here.

commented

There could be one other cause apparently, which is when JDA would load the AudioManager at shutdown to shut it down again (This is a thing apparently) which may cause such a weird behaviour...

Just forwarding what I got from the JDA Discord.

commented

Will be mitigated in JDA 5 update #4786