Fix ConcurrentModificationException
This commit is contained in:
parent
583afd3dc9
commit
e0dfefb72b
|
@ -83,7 +83,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
||||||
arpTable[frame.query] = frame.source
|
arpTable[frame.query] = frame.source
|
||||||
println("$this ($ipAddress) received ARP response for ${frame.query} with ${frame.source}")
|
println("$this ($ipAddress) received ARP response for ${frame.query} with ${frame.source}")
|
||||||
|
|
||||||
packetQueue.removeIf { (packet, _) ->
|
val toRemove = packetQueue.filter { (packet, _) ->
|
||||||
if (packet.destination == frame.query) {
|
if (packet.destination == frame.query) {
|
||||||
send(BasePacketFrame(packet, macAddress, frame.source))
|
send(BasePacketFrame(packet, macAddress, frame.source))
|
||||||
true
|
true
|
||||||
|
@ -91,6 +91,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
packetQueue.removeAll(toRemove)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun sendPacket(packet: Packet) {
|
override fun sendPacket(packet: Packet) {
|
||||||
|
@ -118,7 +119,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
||||||
counter++
|
counter++
|
||||||
|
|
||||||
if (!world!!.isClient) {
|
if (!world!!.isClient) {
|
||||||
packetQueue.removeIf { entry ->
|
val toRemove = packetQueue.filter { entry ->
|
||||||
val (packet, timestamp) = entry
|
val (packet, timestamp) = entry
|
||||||
if (arpTable.containsKey(packet.destination)) {
|
if (arpTable.containsKey(packet.destination)) {
|
||||||
send(BasePacketFrame(packet, macAddress, arpTable[packet.destination]!!))
|
send(BasePacketFrame(packet, macAddress, arpTable[packet.destination]!!))
|
||||||
|
@ -132,6 +133,7 @@ abstract class DeviceBlockEntity(type: BlockEntityType<*>): BlockEntity(type),
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
packetQueue.removeAll(toRemove)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue