From 51c13b4557ee5acc01e8d8fcf38d891578fa9398 Mon Sep 17 00:00:00 2001 From: QwQ-dev Date: Sun, 22 Dec 2024 14:38:21 +0800 Subject: [PATCH] fix: https://github.com/FairyProject/fairy/issues/176. --- .../container/node/loader/ContainerNodeLoader.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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))