Skip to content

Commit

Permalink
trim application name of old mapping content (#14133)
Browse files Browse the repository at this point in the history
* trim application name of old mapping content

* trim and filter out empty name at ServiceNameMapping#getAppNames

* remove unused import
  • Loading branch information
zrlw authored May 8, 2024
1 parent faefee2 commit 8863604
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
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;

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;

Expand Down Expand Up @@ -88,7 +89,10 @@ static Set<String> 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<String> getMappingByUrl(URL consumerURL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8863604

Please sign in to comment.