From f1f5e2947139fb48e04d9fc583fbec1fb9a09a7a Mon Sep 17 00:00:00 2001 From: Moary Chen Date: Wed, 8 Jan 2025 09:22:24 +0800 Subject: [PATCH] The PropertiesMerger implementation not handling property CustomEndpointAddress (#43706) --- sdk/spring/CHANGELOG.md | 5 +++++ .../properties/merger/ProcessorPropertiesMerger.java | 1 + .../properties/merger/ProcessorPropertiesParentMerger.java | 1 + .../properties/merger/SenderPropertiesParentMerger.java | 2 ++ .../merger/ProcessorPropertiesParentMergerTests.java | 6 ++++++ 5 files changed, 15 insertions(+) diff --git a/sdk/spring/CHANGELOG.md b/sdk/spring/CHANGELOG.md index 4781af89092c..e170dc897681 100644 --- a/sdk/spring/CHANGELOG.md +++ b/sdk/spring/CHANGELOG.md @@ -9,6 +9,11 @@ This section includes changes in `spring-cloud-azure-autoconfigure` module. #### Bugs Fixed - Fix bug: Registered the empty value for ineligible definition, it causes NPE when sending message via bean `StreamBridge`. [#43366](https://github.com/Azure/azure-sdk-for-java/issues/43366). +### Spring Messaging Azure Service Bus +This section includes changes in the `spring-messaging-azure-servicebus` module. + +#### Bugs Fixed +- Fix bug: The `PropertiesMerger` implementation not handling property `CustomEndpointAddress`. [#43555](https://github.com/Azure/azure-sdk-for-java/issues/43555). ## 5.19.0 (2024-12-17) - This release is compatible with Spring Boot 3.4.0, 3.3.0-3.3.6, 3.2.0-3.2.12, 3.1.0-3.1.12, 3.0.0-3.0.13. (Note: 3.4.x (x>0), 3.3.y (y>6) and 3.2.z (z>12) should be supported, but they aren't tested with this release.) diff --git a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesMerger.java b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesMerger.java index 98ce3a77c9c2..85de072739b4 100644 --- a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesMerger.java +++ b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesMerger.java @@ -46,6 +46,7 @@ public static void copyProcessorPropertiesIfNotNull(ProcessorProperties source, propertyMapper.from(source.getEntityType()).to(target::setEntityType); propertyMapper.from(source.getMaxConcurrentSessions()).to(target::setMaxConcurrentSessions); propertyMapper.from(source.getMaxConcurrentCalls()).to(target::setMaxConcurrentCalls); + propertyMapper.from(source.getCustomEndpointAddress()).to(target::setCustomEndpointAddress); propertyMapper.from(source.getSessionEnabled()).to(target::setSessionEnabled); propertyMapper.from(source.getAutoComplete()).to(target::setAutoComplete); diff --git a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMerger.java b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMerger.java index 24a388b03ef3..5ed82165733c 100644 --- a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMerger.java +++ b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMerger.java @@ -37,6 +37,7 @@ public ProcessorProperties merge(ProcessorProperties child, NamespaceProperties propertyMapper.from(parent.getConnectionString()).to(properties::setConnectionString); propertyMapper.from(parent.getEntityName()).to(properties::setEntityName); propertyMapper.from(parent.getEntityType()).to(properties::setEntityType); + propertyMapper.from(parent.getCustomEndpointAddress()).to(properties::setCustomEndpointAddress); // If a same property appears in both two objects, the value from the child will take precedence. ProcessorPropertiesMerger.copyProcessorPropertiesIfNotNull(child, properties); diff --git a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/SenderPropertiesParentMerger.java b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/SenderPropertiesParentMerger.java index dfd4848ec051..d0b8b651d1a9 100644 --- a/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/SenderPropertiesParentMerger.java +++ b/sdk/spring/spring-messaging-azure-servicebus/src/main/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/SenderPropertiesParentMerger.java @@ -38,12 +38,14 @@ public ProducerProperties merge(ProducerProperties child, NamespaceProperties pa propertyMapper.from(parent.getConnectionString()).to(properties::setConnectionString); propertyMapper.from(parent.getEntityName()).to(properties::setEntityName); propertyMapper.from(parent.getEntityType()).to(properties::setEntityType); + propertyMapper.from(parent.getCustomEndpointAddress()).to(properties::setCustomEndpointAddress); propertyMapper.from(child.getDomainName()).to(properties::setDomainName); propertyMapper.from(child.getNamespace()).to(properties::setNamespace); propertyMapper.from(child.getConnectionString()).to(properties::setConnectionString); propertyMapper.from(child.getEntityName()).to(properties::setEntityName); propertyMapper.from(child.getEntityType()).to(properties::setEntityType); + propertyMapper.from(child.getCustomEndpointAddress()).to(properties::setCustomEndpointAddress); return properties; diff --git a/sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMergerTests.java b/sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMergerTests.java index f934e4445d1a..e708e243cbcc 100644 --- a/sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMergerTests.java +++ b/sdk/spring/spring-messaging-azure-servicebus/src/test/java/com/azure/spring/messaging/servicebus/implementation/properties/merger/ProcessorPropertiesParentMergerTests.java @@ -20,11 +20,13 @@ public class ProcessorPropertiesParentMergerTests { void childNotProvidedShouldUseParent() { ProcessorProperties child = new ProcessorProperties(); + String customEndpoint = "https://test.address.com:443"; NamespaceProperties parent = new NamespaceProperties(); parent.setConnectionString("parent-connection-str"); parent.getProxy().setHostname("parent-hostname"); parent.getProfile().setCloudType(AZURE_US_GOVERNMENT); parent.setDomainName("parent-domain"); + parent.setCustomEndpointAddress(customEndpoint); parent.getClient().setTransportType(AmqpTransportType.AMQP_WEB_SOCKETS); ProcessorProperties result = merger.merge(child, parent); @@ -35,6 +37,7 @@ void childNotProvidedShouldUseParent() { Assertions.assertEquals(AzureEnvironment.AZURE_US_GOVERNMENT.getActiveDirectoryEndpoint(), result.getProfile().getEnvironment().getActiveDirectoryEndpoint()); Assertions.assertEquals("parent-domain", result.getDomainName()); + Assertions.assertEquals(customEndpoint, result.getCustomEndpointAddress()); Assertions.assertEquals(AmqpTransportType.AMQP_WEB_SOCKETS, result.getClient().getTransportType()); } @@ -47,6 +50,7 @@ void childProvidedShouldUseChild() { child.setMaxConcurrentCalls(2); child.getProfile().setCloudType(AZURE_CHINA); child.setDomainName("child-domain"); + child.setCustomEndpointAddress("https://child.address.com:443"); child.getClient().setTransportType(AmqpTransportType.AMQP); NamespaceProperties parent = new NamespaceProperties(); @@ -54,6 +58,7 @@ void childProvidedShouldUseChild() { parent.getProxy().setHostname("parent-hostname"); parent.getProfile().setCloudType(AZURE_US_GOVERNMENT); parent.setDomainName("parent-domain"); + parent.setCustomEndpointAddress("https://parent.address.com:443"); parent.getClient().setTransportType(AmqpTransportType.AMQP_WEB_SOCKETS); ProcessorProperties result = merger.merge(child, parent); @@ -63,6 +68,7 @@ void childProvidedShouldUseChild() { Assertions.assertEquals(3, result.getPrefetchCount()); Assertions.assertEquals(2, result.getMaxConcurrentCalls()); Assertions.assertEquals("child-domain", result.getDomainName()); + Assertions.assertEquals("https://child.address.com:443", result.getCustomEndpointAddress()); Assertions.assertEquals(AZURE_CHINA, result.getProfile().getCloudType()); Assertions.assertEquals(AzureEnvironment.AZURE_CHINA.getActiveDirectoryEndpoint(), result.getProfile().getEnvironment().getActiveDirectoryEndpoint());