Error in console Task #55
Resoluciones opened this issue ยท 4 comments
What were you doing when this happened? Everything is coded to run synchronously so this should never happen. Are you running some custom version of CB/Spigot?
Hi Scyntrus, I'm not sure unfortunately what originated that eror, I just saw the error in console but I was not online.
I'm running last Paper build, but I didn't notice any change or problem with FM when I replaced the Spigot some months ago.
ConcurrentModificationExceptions don't only happen in multi threaded environments but also when a collection is modified while iterating. In this case, because something inside this loop adds or removes values from FactionMobs.mobList while iterating over it.
for (FactionMob fmob : FactionMobs.mobList) {...
Easiest fix would be to make mobList a CopyOnWriteArrayList or to produce a concurrent hash set from a ConcurrentHashMap.
public static Set<FactionMob> mobList = Collections.newSetFromMap(new ConcurrentHashMap<FactionMob, Object>());
public static Set<FactionMob> mobList = ConcurrentHashMap.newKeySet(); // I think this is how it's done in Java 8?
Instead, you could find out where the addition / removal of values happens, add them to a new collection outside of the loop and to do the actions after the loop.