Skip to content

ConcurrentModificationException when breaking linked relay #230

Description

@Robotgiggle

Minecraft version

1.20.1

Hex Casting version

0.11.3

Hexal version

0.3.1

Issue description

Sometimes, when breaking a relay that is linked to other relays, the BlockEntityRelay.disconnectAll method throws a ConcurrentModificationException as shown below:

[19:00:11] [Server thread/ERROR]: Failed to handle packet net.minecraft.class_2846@74dfea74, suppressing error
java.util.ConcurrentModificationException: null
	at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:756) ~[?:?]
	at java.util.LinkedHashMap$LinkedKeyIterator.next(LinkedHashMap.java:778) ~[?:?]
	at ram.talia.hexal.common.blocks.entity.BlockEntityRelay.disconnectAll(BlockEntityRelay.kt:230) ~[hexal-fabric-1.20.1-0.3.1.jar:?]

This is particularly unusual as disconnectAll loops over and modifies a MutableSet, the documentation for which explicitly states that modifying the set mid-iteration is allowed.

Steps to reproduce

  • Place down some relays
  • Link them together
  • Break a relay that is connected to multiple other relays
  • Observe error in log

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions