From c11d0d3f5ae9b2e17274c553a82eec629611c42b Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 1 Aug 2023 14:23:30 +0200 Subject: [PATCH] Added missing async awaits in notifications that ensures objects are not disposed too early Fixes https://github.com/umbraco/Umbraco-CMS/issues/14574 --- src/Umbraco.Core/Events/EventAggregator.Notifications.cs | 4 ++-- src/Umbraco.Core/Events/EventAggregator.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Core/Events/EventAggregator.Notifications.cs b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs index d65c8f772c..5676af3f3c 100644 --- a/src/Umbraco.Core/Events/EventAggregator.Notifications.cs +++ b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs @@ -238,7 +238,7 @@ internal class NotificationAsyncHandlerWrapperImpl : Notifica /// confusion. /// /// - public override Task HandleAsync( + public override async Task HandleAsync( IEnumerable notifications, CancellationToken cancellationToken, ServiceFactory serviceFactory, @@ -256,7 +256,7 @@ internal class NotificationAsyncHandlerWrapperImpl : Notifica .Select(x => new Func, CancellationToken, Task>( (handlerNotifications, handlerCancellationToken) => x.HandleAsync(handlerNotifications.Cast(), handlerCancellationToken))); - return publish(handlers, notifications, cancellationToken); + await publish(handlers, notifications, cancellationToken); } } diff --git a/src/Umbraco.Core/Events/EventAggregator.cs b/src/Umbraco.Core/Events/EventAggregator.cs index caaa160146..9861b1a318 100644 --- a/src/Umbraco.Core/Events/EventAggregator.cs +++ b/src/Umbraco.Core/Events/EventAggregator.cs @@ -42,13 +42,13 @@ public partial class EventAggregator : IEventAggregator } /// - public Task PublishAsync(IEnumerable notifications, CancellationToken cancellationToken = default) + public async Task PublishAsync(IEnumerable notifications, CancellationToken cancellationToken = default) where TNotification : INotification where TNotificationHandler : INotificationHandler { PublishNotifications(notifications); - return PublishNotificationsAsync(notifications, cancellationToken); + await PublishNotificationsAsync(notifications, cancellationToken); } ///