goshimmer
goshimmer copied to clipboard
OrderedMap.ForEach is not "really" thread safe
Bug description
OrderedMap.ForEach can result in a situation, where the iteration order is somewhat undefined while we are iterating if the elements get mutated during the iteration
Expected behaviour
Calling ForEach should give us the elements that are in the map by the time ForEach is called (make a copy).
Actual behaviour
Calling ForEach locks only each iterated entry, which means that if the order changes in between, we might miss or skip some entries.