From aee6a066a9edb0eec4a5aba7ab6b7656a27ff98f Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Tue, 6 Dec 2022 15:56:47 +0800 Subject: [PATCH 1/3] remove some meaningless jms properties --- ...ServiceBusJmsConnectionFactoryFactory.java | 12 ++- .../AzureServiceBusJmsProperties.java | 74 ------------------- .../AzureServiceBusJmsPropertiesTests.java | 12 --- 3 files changed, 9 insertions(+), 89 deletions(-) diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/ServiceBusJmsConnectionFactoryFactory.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/ServiceBusJmsConnectionFactoryFactory.java index 789ed8ba13bda..fd0f5905af41c 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/ServiceBusJmsConnectionFactoryFactory.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/ServiceBusJmsConnectionFactoryFactory.java @@ -4,6 +4,7 @@ package com.azure.spring.cloud.autoconfigure.jms; import com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties; +import com.azure.spring.cloud.core.implementation.connectionstring.ServiceBusConnectionString; import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -19,6 +20,8 @@ public class ServiceBusJmsConnectionFactoryFactory { private final AzureServiceBusJmsProperties properties; private final List factoryCustomizers; + private static final String AMQP_URI_FORMAT = "amqps://%s?amqp.idleTimeout=%d"; + ServiceBusJmsConnectionFactoryFactory(AzureServiceBusJmsProperties properties, List factoryCustomizers) { Assert.notNull(properties, "Properties must not be null"); @@ -54,9 +57,12 @@ private void setPrefetchPolicy(T fact private T createConnectionFactoryInstance(Class factoryClass) { try { T factory; - String remoteUrl = this.properties.getRemoteUrl(); - String username = this.properties.getUsername(); - String password = this.properties.getPassword(); + ServiceBusConnectionString serviceBusConnectionString = new ServiceBusConnectionString(properties.getConnectionString()); + String host = serviceBusConnectionString.getEndpointUri().getHost(); + + String remoteUrl = String.format(AMQP_URI_FORMAT, host, properties.getIdleTimeout().toMillis()); + String username = serviceBusConnectionString.getSharedAccessKeyName(); + String password = serviceBusConnectionString.getSharedAccessKey(); if (StringUtils.hasLength(username) && StringUtils.hasLength(password)) { factory = factoryClass.getConstructor(String.class, String.class, String.class) diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/properties/AzureServiceBusJmsProperties.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/properties/AzureServiceBusJmsProperties.java index 07ff7b7274ff9..4fc824eee1400 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/properties/AzureServiceBusJmsProperties.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/jms/properties/AzureServiceBusJmsProperties.java @@ -3,7 +3,6 @@ package com.azure.spring.cloud.autoconfigure.jms.properties; -import com.azure.spring.cloud.core.implementation.connectionstring.ServiceBusConnectionString; import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.jms.JmsPoolConnectionFactoryProperties; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -29,9 +28,6 @@ public class AzureServiceBusJmsProperties implements InitializingBean { */ private boolean enabled = true; - private static final String DEFAULT_REMOTE_URL = "amqp://localhost:5672"; - - private static final String AMQP_URI_FORMAT = "amqps://%s?amqp.idleTimeout=%d"; /** * Connection string to connect to a Service Bus namespace. */ @@ -56,21 +52,6 @@ public class AzureServiceBusJmsProperties implements InitializingBean { @NestedConfigurationProperty private final JmsPoolConnectionFactoryProperties pool = new JmsPoolConnectionFactoryProperties(); - /** - * URL of the AMQP broker. Auto-generated by default. - */ - private String remoteUrl = DEFAULT_REMOTE_URL; - - /** - * Login user of the AMQP broker. - */ - private String username; - - /** - * Login password of the AMQP broker. - */ - private String password; - /** * Whether to enable Service Bus JMS autoconfiguration. * @return Whether to enable Service Bus autoconfiguration @@ -87,54 +68,6 @@ public void setEnabled(boolean enabled) { this.enabled = enabled; } - /** - * Get the URL of the AMQP broker. - * @return the URL of the AMQP broker. - */ - public String getRemoteUrl() { - return remoteUrl; - } - - /** - * Set the URL of the AMQP broker. - * @param remoteUrl the URL of the AMQP broker. - */ - public void setRemoteUrl(String remoteUrl) { - this.remoteUrl = remoteUrl; - } - - /** - * Get the login user of the AMQP broker. - * @return the login user of the AMQP broker. - */ - public String getUsername() { - return username; - } - - /** - * Set the login user of the AMQP broker. - * @param username the login user of the AMQP broker. - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Get the login password of the AMQP broker. - * @return the login password of the AMQP broker. - */ - public String getPassword() { - return password; - } - - /** - * Set the login password of the AMQP broker. - * @param password the login password of the AMQP broker. - */ - public void setPassword(String password) { - this.password = password; - } - /** * The properties for a pooled connection factory. * @return the properties for a pooled connection factory. @@ -237,13 +170,6 @@ public void afterPropertiesSet() throws Exception { if (null == pricingTier || !pricingTier.matches("(?i)premium|standard|basic")) { throw new IllegalArgumentException("'spring.jms.servicebus.pricing-tier' is not valid"); } - - ServiceBusConnectionString serviceBusConnectionString = new ServiceBusConnectionString(connectionString); - String host = serviceBusConnectionString.getEndpointUri().getHost(); - - this.remoteUrl = String.format(AMQP_URI_FORMAT, host, idleTimeout.toMillis()); - this.username = serviceBusConnectionString.getSharedAccessKeyName(); - this.password = serviceBusConnectionString.getSharedAccessKey(); } /** diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/jms/AzureServiceBusJmsPropertiesTests.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/jms/AzureServiceBusJmsPropertiesTests.java index e1b54ec1a10a5..2001b29260590 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/jms/AzureServiceBusJmsPropertiesTests.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/test/java/com/azure/spring/cloud/autoconfigure/jms/AzureServiceBusJmsPropertiesTests.java @@ -9,7 +9,6 @@ import org.junit.jupiter.params.provider.NullAndEmptySource; import org.junit.jupiter.params.provider.ValueSource; -import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -45,15 +44,4 @@ void pricingTierNotValid(String pricingTier) { assertTrue(actualMessage.contains(expectedMessage)); } - @ParameterizedTest - @ValueSource(strings = { "basic", "standard", "premium" }) - void setConnectionStringFormatCorrect(String pricingTier) throws Exception { - AzureServiceBusJmsProperties prop = new AzureServiceBusJmsProperties(); - prop.setConnectionString(CONNECTION_STRING); - prop.setPricingTier(pricingTier); - prop.afterPropertiesSet(); - assertThat(prop.getUsername()).isEqualTo("sasKeyName"); - assertThat(prop.getPassword()).isEqualTo("sasKey"); - assertThat(prop.getRemoteUrl()).isEqualTo("amqps://host?amqp.idleTimeout=1800000"); - } } From 747f9250c544b6eeab08da0517423a2c4a261dcb Mon Sep 17 00:00:00 2001 From: Shili Chen Date: Wed, 14 Dec 2022 14:03:13 +0800 Subject: [PATCH 2/3] Fix revapi failures --- .../src/main/resources/revapi/revapi.json | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/eng/code-quality-reports/src/main/resources/revapi/revapi.json b/eng/code-quality-reports/src/main/resources/revapi/revapi.json index ec7a86cce1d78..6dad40a5d01ae 100644 --- a/eng/code-quality-reports/src/main/resources/revapi/revapi.json +++ b/eng/code-quality-reports/src/main/resources/revapi/revapi.json @@ -370,6 +370,36 @@ "new": "class com\\.azure\\.messaging\\.eventhubs\\..*", "justification": "SDK classes are allowed to be exposed by dependencies using them." }, + { + "code": "java.method.removed", + "old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getPassword()", + "justification": "Remove some meaningless jms properties" + }, + { + "code": "java.method.removed", + "old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getRemoteUrl()", + "justification": "Remove some meaningless jms properties" + }, + { + "code": "java.method.removed", + "old": "method java.lang.String com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::getUsername()", + "justification": "Remove some meaningless jms properties" + }, + { + "code": "java.method.removed", + "old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setPassword(java.lang.String)", + "justification": "Remove some meaningless jms properties" + }, + { + "code": "java.method.removed", + "old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setRemoteUrl(java.lang.String)", + "justification": "Remove some meaningless jms properties" + }, + { + "code": "java.method.removed", + "old": "method void com.azure.spring.cloud.autoconfigure.jms.properties.AzureServiceBusJmsProperties::setUsername(java.lang.String)", + "justification": "Remove some meaningless jms properties" + }, { "regex": true, "code": "java.method.numberOfParametersChanged", From 6920f0ae00c781917421923b6d37915b3dbcbf8f Mon Sep 17 00:00:00 2001 From: Shili Chen Date: Wed, 21 Dec 2022 10:35:56 +0800 Subject: [PATCH 3/3] Add changelog --- sdk/spring/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/spring/CHANGELOG.md b/sdk/spring/CHANGELOG.md index 74a8db7957392..43b811068ab80 100644 --- a/sdk/spring/CHANGELOG.md +++ b/sdk/spring/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 4.6.0-beta.1 (Unreleased) + +### Spring Cloud Azure Autoconfigure +This section includes changes in `spring-cloud-azure-autoconfigure` module. + +#### Breaking Changes +- Delete properties: `spring.jms.serviebus.username`, `spring.jms.serviebus.password` and `spring.jms.serviebus.remote-uri` [#32467](https://github.com/Azure/azure-sdk-for-java/pull/32467). + ## 6.0.0-beta.4 (2022-12-07) Upgrade Spring Boot dependencies version to 3.0.0-RC2 and Spring Cloud dependencies version to 2022.0.0-RC2.