diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java index b72560897cd4..67dc74bb29cc 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java @@ -619,6 +619,7 @@ private void useRegistryForConfigIfNecessary() { Environment.getInstance().getDynamicConfiguration().orElseGet(() -> { ConfigManager configManager = ConfigManager.getInstance(); ConfigCenterConfig cc = configManager.getConfigCenter().orElse(new ConfigCenterConfig()); + cc.setClient(rc.getClient()); cc.setProtocol(rc.getProtocol()); cc.setAddress(rc.getAddress()); cc.setHighestPriority(false); diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java index 7caae5634ecf..491cae1bd632 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ConfigCenterConfig.java @@ -86,6 +86,11 @@ public class ConfigCenterConfig extends AbstractConfig { */ private Map parameters; + /* + * as same as org.apache.dubbo.config.RegistryConfig.client + */ + private String client; + public ConfigCenterConfig() { } @@ -228,6 +233,14 @@ public void setParameters(Map parameters) { this.parameters = parameters; } + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + @Override @Parameter(excluded = true) public boolean isValid() { diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java index 96e55825d747..2a61e8dc875b 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java @@ -29,4 +29,11 @@ public void testPrefix() { ConfigCenterConfig config = new ConfigCenterConfig(); Assertions.assertEquals("dubbo.config-center", config.getPrefix()); } + + @Test + public void testAppendClientToUrl() { + ConfigCenterConfig config = new ConfigCenterConfig(); + config.setClient("zk"); + Assertions.assertEquals(config.toUrl().getParameter("client"), config.getClient()); + } }