From e52bc821e10d219f94a5defa27ddce02cb584278 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 2 Jan 2025 12:08:51 +0800 Subject: [PATCH 1/2] Avoid `HandlerFactories` being changed during iteration. Resolve #20625 --- .../src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs index ef5c5cdabc..7c60d69063 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs @@ -135,7 +135,7 @@ public abstract class EventBusBase : IEventBus { await new SynchronizationContextRemover(); - foreach (var handlerFactories in GetHandlerFactories(eventType)) + foreach (var handlerFactories in GetHandlerFactories(eventType).ToList()) { foreach (var handlerFactory in handlerFactories.EventHandlerFactories) { From 1ebeb2fcfa5bf97d0ddf9342e59a39ce6622c2cd Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 2 Jan 2025 12:10:45 +0800 Subject: [PATCH 2/2] Update EventBusBase.cs --- .../src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs index 7c60d69063..151a149281 100644 --- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs +++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs @@ -137,7 +137,7 @@ public abstract class EventBusBase : IEventBus foreach (var handlerFactories in GetHandlerFactories(eventType).ToList()) { - foreach (var handlerFactory in handlerFactories.EventHandlerFactories) + foreach (var handlerFactory in handlerFactories.EventHandlerFactories.ToList()) { await TriggerHandlerAsync(handlerFactory, handlerFactories.EventType, eventData, exceptions, inboxConfig); }