Fixed ConfigNode#remove ConcurrentModificationException

This commit is contained in:
Rsl1122 2019-01-08 11:06:36 +02:00
parent c4a0e18dd9
commit 2b4281ee53

View File

@ -126,11 +126,12 @@ public class ConfigNode {
parent.nodeOrder.remove(key); parent.nodeOrder.remove(key);
updateParent(null); updateParent(null);
for (String key : nodeOrder) { // Remove children recursively to avoid memory leaks
ConfigNode child = childNodes.get(key); nodeOrder.stream()
if (child != null) child.remove(); .sorted() // will use internal state and prevent Concurrent modification of underlying list
} .map(childNodes::get)
.filter(Objects::nonNull)
.forEach(ConfigNode::remove);
} }
/** /**