Fixed #398 - Concurrent modification during grid reconstruction

This commit is contained in:
Calclavia 2014-03-08 14:29:09 -08:00
parent b51029e578
commit 9fa649312a

View file

@ -21,21 +21,24 @@ public abstract class NodeGrid<N extends Node> extends Grid<N>
AbstractMap<Object, ForgeDirection> connections = node.getConnections();
for (Object connection : connections.keySet())
synchronized (connections)
{
if (isValidNode(connection) && connection instanceof Node)
for (Object connection : connections.keySet())
{
Node connectedNode = (Node) connection;
if (connectedNode.getGrid() != this)
if (isValidNode(connection) && connection instanceof Node)
{
synchronized (connectedNode.getGrid().getNodes())
Node connectedNode = (Node) connection;
if (connectedNode.getGrid() != this)
{
connectedNode.getGrid().getNodes().clear();
synchronized (connectedNode.getGrid().getNodes())
{
connectedNode.getGrid().getNodes().clear();
}
add((N) connectedNode);
reconstructNode((N) connectedNode);
}
add((N) connectedNode);
reconstructNode((N) connectedNode);
}
}
}