From 5da7f37038418ad08681db86f3c439f69b081635 Mon Sep 17 00:00:00 2001 From: beiwei30 Date: Fri, 4 Jan 2019 12:44:16 +0800 Subject: [PATCH 1/4] avoid dup refresh for registry config --- .../java/org/apache/dubbo/config/AbstractInterfaceConfig.java | 1 - .../src/main/java/org/apache/dubbo/config/ReferenceConfig.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) 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 80ddcda1a88..87cf70985ab 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 @@ -228,7 +228,6 @@ protected void checkMetadataReport() { */ protected List loadRegistries(boolean provider) { // check && override if necessary - checkRegistry(); List registryList = new ArrayList(); if (registries != null && !registries.isEmpty()) { for (RegistryConfig config : registries) { diff --git a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java index 898f4e6c797..5dcf189a196 100644 --- a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java +++ b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java @@ -218,6 +218,7 @@ public void checkAndUpdateSubConfigs() { inheritIfAbsentFromApplication(); } checkApplication(); + checkRegistry(); checkMetadataReport(); } From 4e3380fe5adbe772602e598fb26f0d16007858e7 Mon Sep 17 00:00:00 2001 From: laoqie Date: Fri, 4 Jan 2019 15:57:30 +0800 Subject: [PATCH 2/4] fix unit test --- .../org/apache/dubbo/config/AbstractInterfaceConfigTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java index 374d7353038..5f7b9612c5f 100644 --- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java +++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractInterfaceConfigTest.java @@ -118,6 +118,8 @@ public void checkApplication2() throws Exception { public void testLoadRegistries() throws Exception { System.setProperty("dubbo.registry.address", "addr1"); InterfaceConfig interfaceConfig = new InterfaceConfig(); + // FIXME: now we need to check first, then load + interfaceConfig.checkRegistry(); List urls = interfaceConfig.loadRegistries(true); TestCase.assertEquals(1, urls.size()); URL url = urls.get(0); From 633f66eb55f7856e02c7c04b2440553fc30b41b2 Mon Sep 17 00:00:00 2001 From: Ian Luo Date: Fri, 4 Jan 2019 17:10:48 +0800 Subject: [PATCH 3/4] fix unit test, org.apache.dubbo.config.AbstractInterfaceConfig#convertRegistryIdsToRegistries generates invalid registry config --- .../java/org/apache/dubbo/config/AbstractInterfaceConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 87cf70985ab..1fa14f8c545 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 @@ -468,7 +468,7 @@ private void convertRegistryIdsToRegistries() { if (StringUtils.isEmpty(registryIds)) { if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); - registries.add(new RegistryConfig()); + registries.add(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); } } else { String[] arr = Constants.COMMA_SPLIT_PATTERN.split(registryIds); @@ -477,7 +477,7 @@ private void convertRegistryIdsToRegistries() { } Arrays.stream(arr).forEach(id -> { if (registries.stream().noneMatch(reg -> reg.getId().equals(id))) { - RegistryConfig registryConfig = new RegistryConfig(); + RegistryConfig registryConfig = new RegistryConfig(RegistryConfig.NO_AVAILABLE); registryConfig.setId(id); registries.add(registryConfig); } From 9c2b8b647de74c1f2195ff7491187b5ed112a6e2 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Sun, 6 Jan 2019 16:05:22 +0800 Subject: [PATCH 4/4] should not give RegistryConfig a default value 'RegistryConfig.NO_AVAILABLE' --- .../java/org/apache/dubbo/config/AbstractInterfaceConfig.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 1fa14f8c545..87cf70985ab 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 @@ -468,7 +468,7 @@ private void convertRegistryIdsToRegistries() { if (StringUtils.isEmpty(registryIds)) { if (registries == null || registries.isEmpty()) { registries = new ArrayList<>(); - registries.add(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); + registries.add(new RegistryConfig()); } } else { String[] arr = Constants.COMMA_SPLIT_PATTERN.split(registryIds); @@ -477,7 +477,7 @@ private void convertRegistryIdsToRegistries() { } Arrays.stream(arr).forEach(id -> { if (registries.stream().noneMatch(reg -> reg.getId().equals(id))) { - RegistryConfig registryConfig = new RegistryConfig(RegistryConfig.NO_AVAILABLE); + RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setId(id); registries.add(registryConfig); }