From 28a200f4f5370a02b3b599be23856fe606f682f6 Mon Sep 17 00:00:00 2001 From: zrlw Date: Fri, 26 Apr 2024 10:04:53 +0800 Subject: [PATCH 1/3] trim application name of old mapping content --- .../registry/client/metadata/MetadataServiceNameMapping.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java index 62322d820b6..57c7dd51d36 100644 --- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java +++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataServiceNameMapping.java @@ -109,7 +109,7 @@ public boolean map(URL url) { String[] oldAppNames = oldConfigContent.split(","); if (oldAppNames.length > 0) { for (String oldAppName : oldAppNames) { - if (oldAppName.equals(appName)) { + if (StringUtils.trim(oldAppName).equals(appName)) { succeeded = true; break; } From f003f549da9ebb6e276ab694b7b2fdb530745908 Mon Sep 17 00:00:00 2001 From: zrlw Date: Fri, 26 Apr 2024 14:48:28 +0800 Subject: [PATCH 2/3] trim and filter out empty name at ServiceNameMapping#getAppNames --- .../java/org/apache/dubbo/metadata/ServiceNameMapping.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java index e2c58e69eb0..a993573ca2e 100644 --- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java +++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java @@ -30,6 +30,8 @@ import java.util.TreeSet; import static java.util.Collections.emptySet; +import static java.util.stream.Collectors.toSet; +import static java.util.stream.Stream.of; import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SEPARATOR; import static org.apache.dubbo.common.extension.ExtensionScope.APPLICATION; @@ -88,7 +90,10 @@ static Set getAppNames(String content) { if (StringUtils.isBlank(content)) { return emptySet(); } - return new TreeSet<>(Arrays.asList(content.split(COMMA_SEPARATOR))); + return new TreeSet<>(of(content.split(COMMA_SEPARATOR)) + .map(String::trim) + .filter(StringUtils::isNotEmpty) + .collect(toSet())); } static Set getMappingByUrl(URL consumerURL) { From 4828d0ee27529580ccd66d0104f9a2b3ac027612 Mon Sep 17 00:00:00 2001 From: zrlw Date: Fri, 26 Apr 2024 15:05:02 +0800 Subject: [PATCH 3/3] remove unused import --- .../main/java/org/apache/dubbo/metadata/ServiceNameMapping.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java index a993573ca2e..91fce3cef42 100644 --- a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java +++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/ServiceNameMapping.java @@ -25,7 +25,6 @@ import org.apache.dubbo.rpc.model.ScopeModelUtil; import org.apache.dubbo.rpc.service.Destroyable; -import java.util.Arrays; import java.util.Set; import java.util.TreeSet;