AcademyCraft

AcademyCraft

1M Downloads

ConcurrentModification while iterating in ClientRuntime#keyStates

WeAthFoLD opened this issue ยท 0 comments

commented
java.util.ConcurrentModificationException
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1429)
    at java.util.HashMap$EntryIterator.next(HashMap.java:1463)
    at java.util.HashMap$EntryIterator.next(HashMap.java:1461)
    at cn.academy.ability.api.context.ClientRuntime$Events.onClientTick(ClientRuntime.java:311)

This happens because we call the onKeyDown inside the loop, which delegates to ClientRuntime#addKey and modifies the map. I think the add method's modification process shall be deferred to ticking loop.