diff --git a/framework/platforms/core-platform/src/main/java/io/fairyproject/container/node/loader/ContainerNodeLoader.java b/framework/platforms/core-platform/src/main/java/io/fairyproject/container/node/loader/ContainerNodeLoader.java index 16e1ffa2..7489f86f 100644 --- a/framework/platforms/core-platform/src/main/java/io/fairyproject/container/node/loader/ContainerNodeLoader.java +++ b/framework/platforms/core-platform/src/main/java/io/fairyproject/container/node/loader/ContainerNodeLoader.java @@ -45,6 +45,7 @@ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; @@ -122,7 +123,11 @@ private CompletableFuture findPrototypeInstance(Class type) { private CompletableFuture callPreInitProcessors() { List> futures = new ArrayList<>(); - for (InstanceEntry entry : this.collection) { + // fix ConcurrentModificationException + List snapshot = new ArrayList<>(); + this.collection.forEach(snapshot::add); + + for (InstanceEntry entry : snapshot) { Object instance = entry.getInstance(); ContainerObj object = entry.getContainerObject(); if (!this.trySetLifeCycle(object, LifeCycle.PRE_INIT))