From 15b8a37d035b2a9727052c30dffd010c20dc834e Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 31 Jul 2023 11:11:56 +0800 Subject: [PATCH 1/3] `MapExtraPropertiesTo` should ignored if `ExtraProperties` is `null`. --- .../AbpAutoMapperExtensibleDtoExtensions.cs | 6 ++++++ ...AutoMapperExtensibleDtoExtensions_Tests.cs | 19 ++++++++++++++++++- .../TestObjects/ExtensibleTestPerson.cs | 5 +++++ .../TestObjects/ExtensibleTestPersonDto.cs | 5 ++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs index 5085eecdc2..299b3a17a5 100644 --- a/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs +++ b/framework/src/Volo.Abp.AutoMapper/AutoMapper/AbpAutoMapperExtensibleDtoExtensions.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Volo.Abp; using Volo.Abp.AutoMapper; using Volo.Abp.Data; using Volo.Abp.ObjectExtending; @@ -25,6 +26,11 @@ public static class AbpAutoMapperExtensibleDtoExtensions ? new Dictionary() : new Dictionary(extraProps); + if (source.ExtraProperties == null || destination.ExtraProperties == null) + { + return result; + } + ExtensibleObjectMapper .MapExtraPropertiesTo( source.ExtraProperties, diff --git a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs index 50d8c50a66..4f9dfae22d 100644 --- a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs +++ b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs @@ -1,5 +1,7 @@ -using Microsoft.Extensions.DependencyInjection; +using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; using Shouldly; +using Volo.Abp; using Volo.Abp.AutoMapper; using Volo.Abp.Data; using Volo.Abp.ObjectExtending.TestObjects; @@ -64,4 +66,19 @@ public class AbpAutoMapperExtensibleDtoExtensions_Tests : AbpIntegratedTest _objectMapper.Map(person, personDto)); + + person.ExtraProperties.ShouldBe(null); + personDto.ExtraProperties.ShouldBe(null); + } } diff --git a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPerson.cs b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPerson.cs index 81a08ec227..77e892b1b9 100644 --- a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPerson.cs +++ b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPerson.cs @@ -12,6 +12,11 @@ public class ExtensibleTestPerson : ExtensibleObject { } + + public void SetExtraPropertiesAsNull() + { + ExtraProperties = null; + } } public enum ExtensibleTestEnumProperty diff --git a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPersonDto.cs b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPersonDto.cs index 180e2713b7..103ef37653 100644 --- a/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPersonDto.cs +++ b/framework/test/Volo.Abp.ObjectExtending.Tests/Volo/Abp/ObjectExtending/TestObjects/ExtensibleTestPersonDto.cs @@ -2,5 +2,8 @@ public class ExtensibleTestPersonDto : ExtensibleObject { - + public void SetExtraPropertiesAsNull() + { + ExtraProperties = null; + } } From 48c14e55650e201c40ac75682b87dd88324c7fe5 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 31 Jul 2023 14:27:09 +0800 Subject: [PATCH 2/3] Update AbpAutoMapperExtensibleDtoExtensions_Tests.cs --- .../AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs index 4f9dfae22d..1bb16ce071 100644 --- a/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs +++ b/framework/test/Volo.Abp.AutoMapper.Tests/AutoMapper/AbpAutoMapperExtensibleDtoExtensions_Tests.cs @@ -79,6 +79,6 @@ public class AbpAutoMapperExtensibleDtoExtensions_Tests : AbpIntegratedTest _objectMapper.Map(person, personDto)); person.ExtraProperties.ShouldBe(null); - personDto.ExtraProperties.ShouldBe(null); + personDto.ExtraProperties.ShouldBeEmpty(); } } From 6ba8a1a6b2fe0f1f5027e6b06394fac522fd9cfb Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 31 Jul 2023 17:49:43 +0800 Subject: [PATCH 3/3] Use one-off channels for passive declarations --- .../Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs index 8d4756165a..d08d42fd0c 100644 --- a/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs +++ b/framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs @@ -330,7 +330,10 @@ public class RabbitMqDistributedEventBus : DistributedEventBusBase, ISingletonDe try { - channel.ExchangeDeclarePassive(AbpRabbitMqEventBusOptions.ExchangeName); + using (var temporaryChannel = ConnectionPool.Get(AbpRabbitMqEventBusOptions.ConnectionName).CreateModel()) + { + temporaryChannel.ExchangeDeclarePassive(AbpRabbitMqEventBusOptions.ExchangeName); + } } catch (Exception) {