Fix ConcurrentModificatonException in NetworkEventBus (#3660)

This commit is contained in:
fscan
2018-08-01 00:35:44 +02:00
committed by GitHub
parent f8d5f4ddb1
commit fa2b4fabc7
+13 -3
View File
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Map.Entry;
import appeng.api.networking.IGridNode;
import appeng.api.networking.IMachineSet;
import appeng.api.networking.events.MENetworkEvent;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.core.AELog;
@@ -114,10 +115,19 @@ public class NetworkEventBus
target.invoke( cache.getCache(), e );
}
for( final IGridNode obj : g.getMachines( subscriber.getKey() ) )
// events may create or remove grid nodes in rare cases
final IMachineSet machines = g.getMachines( subscriber.getKey() );
final List<IGridNode> work = new ArrayList<>( machines.size() );
machines.forEach( work::add );
for( final IGridNode obj : work )
{
x++;
target.invoke( obj.getMachine(), e );
// stil part of grid?
if( machines.contains( obj ) )
{
x++;
target.invoke( obj.getMachine(), e );
}
}
}
}