JukeBox Upgrade Crash
csonyi opened this issue ยท 1 comments
During regular usage (I opened the BP, tried taking out an item) My game crashed with the following exception:
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.remove(HashMap.java:1443)
at java.util.Collection.removeIf(Collection.java:415)
at net.p3pp3rf1y.sophisticatedbackpacks.upgrades.jukebox.BackpackSoundHandler.tick(BackpackSoundHandler.java:45)
at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:247)
at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:239)
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)
at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)
at net.minecraftforge.fml.hooks.BasicEventHooks.onPostWorldTick(BasicEventHooks.java:100)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:857)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787)
at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:78)
at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642)
at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232)
at java.lang.Thread.run(Thread.java:745)
Weird thing is, my BP has no jukebox upgrade in it.
Possible fix:
Consider using an Iterator, and use the Iterator's remove method, as that won't cause this kind of exception (AFAIK).
Get the latest version of the mod. It i uses thread safe collection there. My guess is that there is some mod out there which makes it so that what is supposed to only run on one thread runs in more than one. I haven't seen it myself nor had this reported from big packs that thousands of people play. So my guess is the mod isn't used that much.
And regarding the proposed solution - if you look at what removeif does that's exactly what it does behind the scenes - get iterator evaluate condition for each element and then uses remove method of iterator. I have been coding for quite a bit so this is pretty natural stuff.