diff --git a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/filter/JvmFilterHolder.java b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/filter/JvmFilterHolder.java index 03ffd8d5d..0fd5c9971 100644 --- a/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/filter/JvmFilterHolder.java +++ b/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/filter/JvmFilterHolder.java @@ -18,9 +18,8 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -31,7 +30,7 @@ */ public class JvmFilterHolder { - private final List JVM_FILTERS = new ArrayList<>(); + private final List JVM_FILTERS = new CopyOnWriteArrayList<>(); private final AtomicBoolean FILTERS_SORTED = new AtomicBoolean(false); @@ -56,8 +55,8 @@ public List getJvmFilters() { } public static boolean beforeInvoking(JvmFilterContext context) { - List filters = Collections.unmodifiableList(context.getSofaRuntimeContext() - .getJvmFilterHolder().getJvmFilters()); + List filters = context.getSofaRuntimeContext().getJvmFilterHolder() + .getJvmFilters(); for (JvmFilter filter : filters) { if (!filter.before(context)) { return false; @@ -67,8 +66,8 @@ public static boolean beforeInvoking(JvmFilterContext context) { } public static boolean afterInvoking(JvmFilterContext context) { - List filters = Collections.unmodifiableList(context.getSofaRuntimeContext() - .getJvmFilterHolder().getJvmFilters()); + List filters = context.getSofaRuntimeContext().getJvmFilterHolder() + .getJvmFilters(); for (int i = filters.size() - 1; i >= 0; --i) { if (!filters.get(i).after(context)) { return false;