InventivetalentDev / CompactNPCLib

Library to create NPCs
MIT License
22 stars 9 forks source link

Concurrency issue on NPCRegistry.destroy() #20

Closed rlf closed 8 years ago

rlf commented 8 years ago

What steps will reproduce the problem?

  1. Write a plugin that correctly supports onEnable and onDisable (i.e. PlugMan compatible)
  2. Use the NPCRegistry in onEnable, and call destroy in onDisable
  3. Sometimes (when the registry contains NPCs), you will get the stacktrace below:
java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextNode(Unknown Source) ~[?:1.8.0_60]
        at java.util.HashMap$KeyIterator.next(Unknown Source) ~[?:1.8.0_60]
        at org.inventivetalent.npclib.registry.NPCRegistry.destroy(NPCRegistry.java:51) ~[?:?]
        at org.inventivetalent.npclib.registry.NPCRegistry.destroy(NPCRegistry.java:59) ~[?:?]
        at com.github.rlf.pokeamon.PokeAMon.onDisable(PokeAMon.java:40) ~[?:?]

What were you expecting to happen? What happened instead?

The destroy method should either iterate over a copy of the data-model, or use the iterator to remove the items.

What version of the plugin are you using? Type /version <Plugin Name>

2.2.5

null321-jared commented 8 years ago

Yeah it happens to me too, I think all that needs to be changed is making the for-each loop a normal for loop.

InventivetalentDev commented 8 years ago

Should be fixed in v2.2.6.