axieum / minecord

Bring your Minecraft world into your Discord guild
https://www.curseforge.com/minecraft/mc-mods/minecord-for-discord
MIT License
15 stars 7 forks source link

"Name may not be blank" for presence updates on `/reload` command #82

Closed axieum closed 1 year ago

axieum commented 1 year ago

Expected behavior

For /reload to not log any errors.

Observed/actual behavior

[10.06 22:45:49] [Server] [Server thread/INFO]: Adding presence category 'starting' with 1 presences
[10.06 22:45:49] [Server] [Server thread/INFO]: Adding presence category 'running' with 3 presences
[10.06 22:45:49] [Server] [Server thread/INFO]: Scheduling Discord bot presence updates with category 'running' for every 60 second(s)
[10.06 22:45:49] [Server] [Server thread/INFO]: Adding presence category 'stopping' with 1 presences
[10.06 22:45:49] [Server] [Minecord-Presence-Timer/ERROR]: Unable to update the Discord bot presence!
[10.06 22:45:49] [Server] java.lang.IllegalArgumentException Name may not be blank
[10.06 22:45:49] [Server]   at net.dv8tion.jda.internal.utils.Checks.notBlank(Checks.java:99) ~[minecord-api-2.0.1+1.20-a234684e30a65c97.jar:?]
[10.06 22:45:49] [Server]   at net.dv8tion.jda.api.entities.Activity.playing(Activity.java:128) ~[minecord-api-2.0.1+1.20-a234684e30a65c97.jar:?]
[10.06 22:45:49] [Server]   at net.dv8tion.jda.api.entities.Activity.of(Activity.java:284) ~[minecord-api-2.0.1+1.20-a234684e30a65c97.jar:?]
[10.06 22:45:49] [Server]   at me.axieum.mcmod.minecord.impl.presence.config.PresenceConfig$CategorySchema$PresenceSchema$1.lambda$getActivity$0(PresenceConfig.java:194) ~[minecord-presence-2.0.0+1.20-369ccbe8bac604fd.jar:?]
[10.06 22:45:49] [Server]   at java.util.Optional.map(Optional.java:260) ~[?:?]
[10.06 22:45:49] [Server]   at me.axieum.mcmod.minecord.impl.presence.config.PresenceConfig$CategorySchema$PresenceSchema$1.getActivity(PresenceConfig.java:193) ~[minecord-presence-2.0.0+1.20-369ccbe8bac604fd.jar:?]
[10.06 22:45:49] [Server]   at me.axieum.mcmod.minecord.impl.presence.PresenceUpdateTask.run(PresenceUpdateTask.java:76) ~[minecord-presence-2.0.0+1.20-369ccbe8bac604fd.jar:?]
[10.06 22:45:49] [Server]   at java.util.TimerThread.mainLoop(Timer.java:566) ~[?:?]
[10.06 22:45:49] [Server]   at java.util.TimerThread.run(Timer.java:516) ~[?:?]
[10.06 22:45:49] [Multicraft] axieum ran command: reload

Steps/models to reproduce

Run /reload, and there is a high chance that it tries to set a Discord status update with a blank name.

Version

v2.0.1+1.20

Agreements

Other

No response

axieum commented 1 year ago

I cannot reliably reproduce this one - it is most likely a race condition between the /reload thread and the timer task thread accessing the config.