entry : parameters.entrySet()) {
if (!ignoreCheckKeys.contains(entry.getKey())) {
diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java
index 9cc037a8b4b..7bad3d5fdab 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ReferenceConfigCache.java
@@ -29,6 +29,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import static org.apache.dubbo.common.BaseServiceMetadata.buildServiceKey;
+
/**
* A simple util class for cache {@link ReferenceConfigBase}.
*
@@ -54,15 +56,7 @@ public class ReferenceConfigCache {
throw new IllegalArgumentException("No interface info in ReferenceConfig" + referenceConfig);
}
- StringBuilder ret = new StringBuilder();
- if (!StringUtils.isBlank(referenceConfig.getGroup())) {
- ret.append(referenceConfig.getGroup()).append("/");
- }
- ret.append(iName);
- if (!StringUtils.isBlank(referenceConfig.getVersion())) {
- ret.append(":").append(referenceConfig.getVersion());
- }
- return ret.toString();
+ return buildServiceKey(iName, referenceConfig.getGroup(), referenceConfig.getVersion());
};
static final ConcurrentMap CACHE_HOLDER = new ConcurrentHashMap();
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/SslConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/SslConfigTest.java
new file mode 100644
index 00000000000..4547c6ada03
--- /dev/null
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/SslConfigTest.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.config;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+public class SslConfigTest {
+
+ @Test
+ public void testServerKeyCertChainPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setServerKeyCertChainPath("test-server-key-cert-chain-path");
+ assertThat(sslConfig.getServerKeyCertChainPath(),equalTo("test-server-key-cert-chain-path"));
+ }
+
+ @Test
+ public void testServerPrivateKeyPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setServerPrivateKeyPath("test-server-private-key-path");
+ assertThat(sslConfig.getServerPrivateKeyPath(),equalTo("test-server-private-key-path"));
+ }
+
+ @Test
+ public void testServerKeyPassword() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setServerKeyPassword("test-server-key-password");
+ assertThat(sslConfig.getServerKeyPassword(),equalTo("test-server-key-password"));
+ }
+
+ @Test
+ public void testServerTrustCertCollectionPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setServerTrustCertCollectionPath("test-server-trust-cert-collection-path");
+ assertThat(sslConfig.getServerTrustCertCollectionPath(),equalTo("test-server-trust-cert-collection-path"));
+ }
+
+ @Test
+ public void testClientKeyCertChainPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setClientKeyCertChainPath("test-client-trust-cert-collection-path");
+ assertThat(sslConfig.getClientKeyCertChainPath(),equalTo("test-client-trust-cert-collection-path"));
+ }
+
+ @Test
+ public void testClientPrivateKeyPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setClientPrivateKeyPath("test-client-private-key-path");
+ assertThat(sslConfig.getClientPrivateKeyPath(),equalTo("test-client-private-key-path"));
+ }
+
+ @Test
+ public void testClientKeyPassword() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setClientKeyPassword("test-client-key-password");
+ assertThat(sslConfig.getClientKeyPassword(),equalTo("test-client-key-password"));
+ }
+
+ @Test
+ public void testClientTrustCertCollectionPath() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ sslConfig.setClientTrustCertCollectionPath("test-client-trust-cert-collection-path");
+ assertThat(sslConfig.getClientTrustCertCollectionPath(),equalTo("test-client-trust-cert-collection-path"));
+ }
+
+ @Test
+ public void testServerKeyCertChainPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-server-key-cert-chain-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setServerKeyCertChainPathStream(inputStream);
+ assertThat(sslConfig.getServerKeyCertChainPathStream(),equalTo(inputStream));
+ }
+
+ @Test
+ public void testServerPrivateKeyPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-server-private-key-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setServerPrivateKeyPathStream(inputStream);
+ assertThat(sslConfig.getServerPrivateKeyPathStream(),equalTo(inputStream));
+ }
+
+ @Test
+ public void testServerTrustCertCollectionPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-server-trust-cert-collection-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setServerTrustCertCollectionPathStream(inputStream);
+ assertThat(sslConfig.getServerTrustCertCollectionPathStream(),equalTo(inputStream));
+ }
+
+ @Test
+ public void testClientKeyCertChainPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-client-key-cert-chain-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setClientKeyCertChainPathStream(inputStream);
+ assertThat(sslConfig.getClientKeyCertChainPathStream(),equalTo(inputStream));
+ }
+
+ @Test
+ public void testClientPrivateKeyPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-client-private-key-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setClientPrivateKeyPathStream(inputStream);
+ assertThat(sslConfig.getClientPrivateKeyPathStream(),equalTo(inputStream));
+ }
+
+ @Test
+ public void testClientTrustCertCollectionPathStream() throws Exception {
+ SslConfig sslConfig = new SslConfig();
+ String string = "test-client-trust-cert-collection-path-stream";
+ InputStream inputStream = IOUtils.toInputStream(string, StandardCharsets.UTF_8);
+ sslConfig.setClientTrustCertCollectionPathStream(inputStream);
+ assertThat(sslConfig.getClientTrustCertCollectionPathStream(),equalTo(inputStream));
+ }
+
+}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
index e329f235119..1fffe4c1a93 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
@@ -101,21 +101,25 @@ public void compatibleApplicationShutdown() {
@Test
public void testLoadRegistries() {
- System.setProperty("dubbo.registry.address", "addr1");
- AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new AbstractInterfaceConfigTest.InterfaceConfig();
- // FIXME: now we need to check first, then load
- interfaceConfig.setApplication(new ApplicationConfig("testLoadRegistries"));
- interfaceConfig.checkRegistry();
- List urls = ConfigValidationUtils.loadRegistries(interfaceConfig, true);
- Assertions.assertEquals(1, urls.size());
- URL url = urls.get(0);
- Assertions.assertEquals("registry", url.getProtocol());
- Assertions.assertEquals("addr1:9090", url.getAddress());
- Assertions.assertEquals(RegistryService.class.getName(), url.getPath());
- Assertions.assertTrue(url.getParameters().containsKey("timestamp"));
- Assertions.assertTrue(url.getParameters().containsKey("pid"));
- Assertions.assertTrue(url.getParameters().containsKey("registry"));
- Assertions.assertTrue(url.getParameters().containsKey("dubbo"));
+ try {
+ System.setProperty("dubbo.registry.address", "addr1");
+ AbstractInterfaceConfigTest.InterfaceConfig interfaceConfig = new AbstractInterfaceConfigTest.InterfaceConfig();
+ // FIXME: now we need to check first, then load
+ interfaceConfig.setApplication(new ApplicationConfig("testLoadRegistries"));
+ interfaceConfig.checkRegistry();
+ List urls = ConfigValidationUtils.loadRegistries(interfaceConfig, true);
+ Assertions.assertEquals(1, urls.size());
+ URL url = urls.get(0);
+ Assertions.assertEquals("registry", url.getProtocol());
+ Assertions.assertEquals("addr1:9090", url.getAddress());
+ Assertions.assertEquals(RegistryService.class.getName(), url.getPath());
+ Assertions.assertTrue(url.getParameters().containsKey("timestamp"));
+ Assertions.assertTrue(url.getParameters().containsKey("pid"));
+ Assertions.assertTrue(url.getParameters().containsKey("registry"));
+ Assertions.assertTrue(url.getParameters().containsKey("dubbo"));
+ } finally {
+ System.clearProperty("dubbo.registry.address");
+ }
}
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigAliasPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigAliasPostProcessor.java
index 28b6a6cf8b1..e6ea0603bbe 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigAliasPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboConfigAliasPostProcessor.java
@@ -39,7 +39,7 @@ public class DubboConfigAliasPostProcessor implements BeanDefinitionRegistryPost
/**
* The bean name of {@link DubboConfigConfigurationRegistrar}
*/
- public final static String BEAN_NAME = "dubboConfigAliasPostProcessor";
+ public static final String BEAN_NAME = "dubboConfigAliasPostProcessor";
private BeanDefinitionRegistry registry;
diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessor.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessor.java
index aa2ab886f6f..a429358a49b 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessor.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceClassPostProcessor.java
@@ -90,7 +90,7 @@
public class ServiceClassPostProcessor implements BeanDefinitionRegistryPostProcessor, EnvironmentAware,
ResourceLoaderAware, BeanClassLoaderAware {
- private final static List> serviceAnnotationTypes = asList(
+ private static final List> serviceAnnotationTypes = asList(
// @since 2.7.7 Add the @DubboService , the issue : https://github.com/apache/dubbo/issues/6007
DubboService.class,
// @since 2.7.0 the substitute @com.alibaba.dubbo.config.annotation.Service
diff --git a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
index 0fc55896912..a0ea159997f 100644
--- a/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
+++ b/dubbo-config/dubbo-config-spring/src/main/resources/META-INF/dubbo.xsd
@@ -982,6 +982,11 @@
+
+
+
+
+
diff --git a/dubbo-configcenter/dubbo-configcenter-apollo/src/test/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-apollo/src/test/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfigurationTest.java
index b14f172bb91..11ae86a8de1 100644
--- a/dubbo-configcenter/dubbo-configcenter-apollo/src/test/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfigurationTest.java
+++ b/dubbo-configcenter/dubbo-configcenter-apollo/src/test/java/org/apache/dubbo/configcenter/support/apollo/ApolloDynamicConfigurationTest.java
@@ -24,7 +24,10 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.Order;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -41,6 +44,7 @@
* Notice: EmbeddedApollo(apollo mock server) only support < junit5, please not upgrade the junit version in this UT,
* the junit version in this UT is junit4, and the dependency comes from apollo-mockserver.
*/
+@TestMethodOrder(OrderAnnotation.class)
public class ApolloDynamicConfigurationTest {
private static final String SESSION_TIMEOUT_KEY = "session";
private static final String DEFAULT_NAMESPACE = "dubbo";
@@ -84,6 +88,7 @@ public void setUp() {
* Test get rule.
*/
@Test
+ @Order(1)
public void testGetRule() {
String mockKey = "mockKey1";
String mockValue = String.valueOf(new Random().nextInt());
@@ -101,6 +106,7 @@ public void testGetRule() {
* @throws InterruptedException the interrupted exception
*/
@Test
+ @Order(2)
public void testGetInternalProperty() throws InterruptedException {
String mockKey = "mockKey2";
String mockValue = String.valueOf(new Random().nextInt());
@@ -123,6 +129,7 @@ public void testGetInternalProperty() throws InterruptedException {
* @throws Exception the exception
*/
@Test
+ @Order(3)
public void testAddListener() throws Exception {
String mockKey = "mockKey3";
String mockValue = String.valueOf(new Random().nextInt());
@@ -145,6 +152,44 @@ public void process(org.apache.dubbo.common.config.configcenter.ConfigChangedEve
assertEquals(ConfigChangeType.MODIFIED, result.getChangeType());
}
+ /**
+ * Test remove listener.
+ *
+ * @throws Exception the exception
+ */
+ @Test
+ @Order(4)
+ public void testRemoveListener() throws Exception {
+ String mockKey = "mockKey4";
+ String mockValue = String.valueOf(new Random().nextInt());
+
+ final SettableFuture future = SettableFuture.create();
+
+ apolloDynamicConfiguration = new ApolloDynamicConfiguration(url);
+ apolloDynamicConfiguration.addListener(mockKey, DEFAULT_NAMESPACE, new ConfigurationListener() {
+ @Override
+ public void process(org.apache.dubbo.common.config.configcenter.ConfigChangedEvent event) {
+ future.set(event);
+ }
+ });
+
+ putData(mockKey, mockValue);
+ future.get(3000, TimeUnit.MILLISECONDS);
+
+ apolloDynamicConfiguration.removeListener(mockKey, DEFAULT_NAMESPACE, new ConfigurationListener() {
+ @Override
+ public void process(org.apache.dubbo.common.config.configcenter.ConfigChangedEvent event) {
+ future.set(event);
+ }
+ });
+
+ deleteData(mockKey);
+ org.apache.dubbo.common.config.configcenter.ConfigChangedEvent result = future.get(3000, TimeUnit.MILLISECONDS);
+ assertEquals(mockValue, result.getContent());
+ assertEquals(mockKey, result.getKey());
+ assertEquals(ConfigChangeType.MODIFIED, result.getChangeType());
+ }
+
private static void putData(String namespace, String key, String value) {
embeddedApollo.addOrModifyProperty(namespace, key, value);
}
@@ -153,6 +198,9 @@ private static void putData(String key, String value) {
embeddedApollo.addOrModifyProperty(DEFAULT_NAMESPACE, key, value);
}
+ private static void deleteData(String key) {
+ embeddedApollo.deleteProperty(DEFAULT_NAMESPACE, key);
+ }
private static void putMockRuleData(String key, String value, String group) {
String fileName = ApolloDynamicConfigurationTest.class.getResource("/").getPath() + "mockdata-" + group + ".properties";
putMockData(key, value, fileName);
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
index 66bd0e9e528..494b36a8804 100644
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
+++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/CacheListener.java
@@ -57,6 +57,10 @@ public void removeListener(String key, ConfigurationListener configurationListen
}
}
+ public void removeAllListeners() {
+ keyListeners.clear();
+ }
+
public Set getConfigurationListeners(String key) {
return keyListeners.get(key);
}
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
index 6489ab105b8..d445bd3c211 100644
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
+++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/main/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfiguration.java
@@ -28,6 +28,7 @@
import java.util.Collection;
import java.util.Set;
import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -81,6 +82,13 @@ public String getInternalProperty(String key) {
@Override
protected void doClose() throws Exception {
zkClient.close();
+ if (executor instanceof ExecutorService) {
+ ExecutorService executorService = (ExecutorService) executor;
+ if (!executorService.isShutdown()) {
+ executorService.shutdown();
+ }
+ }
+ cacheListener.removeAllListeners();
}
@Override
diff --git a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
index 518ab9a8dfb..1792dcfa049 100644
--- a/dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
+++ b/dubbo-configcenter/dubbo-configcenter-zookeeper/src/test/java/org/apache/dubbo/configcenter/support/zookeeper/ZookeeperDynamicConfigurationTest.java
@@ -31,6 +31,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
@@ -46,6 +47,7 @@
/**
* TODO refactor using mockito
*/
+@Disabled("Disabled Due to Zookeeper in Github Actions")
public class ZookeeperDynamicConfigurationTest {
private CuratorFramework client;
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
index 1e5a7d51b39..b2682e855ef 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/pom.xml
@@ -51,6 +51,14 @@
org.apache.dubbo
dubbo-registry-nacos