Skip to content

Commit

Permalink
[3.0] ignore non-dubbo nacos services (#8573)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Aug 27, 2021
1 parent 24e4bd3 commit bce9641
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.dubbo.registry.RegistryNotifier;
import org.apache.dubbo.registry.nacos.util.NacosInstanceManageUtil;
import org.apache.dubbo.registry.support.FailbackRegistry;
import org.apache.dubbo.rpc.RpcException;

import com.alibaba.nacos.api.common.Constants;
import com.alibaba.nacos.api.exception.NacosException;
Expand All @@ -39,7 +40,6 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.google.common.collect.Lists;
import org.apache.dubbo.rpc.RpcException;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -69,6 +69,7 @@
import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY;
import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY;
import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL;
import static org.apache.dubbo.registry.nacos.NacosServiceName.NAME_SEPARATOR;
import static org.apache.dubbo.registry.nacos.NacosServiceName.valueOf;

/**
Expand Down Expand Up @@ -307,6 +308,7 @@ private Set<String> filterServiceNames(NacosServiceName serviceName) {
serviceNames.addAll(namingService.getServicesOfServer(1, Integer.MAX_VALUE,
getUrl().getGroup(Constants.DEFAULT_GROUP)).getData()
.stream()
.filter(this::isConformRules)
.map(NacosServiceName::new)
.filter(serviceName::isCompatible)
.map(NacosServiceName::toString)
Expand All @@ -317,6 +319,18 @@ private Set<String> filterServiceNames(NacosServiceName serviceName) {
}
}

/**
* Verify whether it is a dubbo service
*
* @param serviceName
* @return
* @since 2.7.12
*/
private boolean isConformRules(String serviceName) {
return serviceName.split(NAME_SEPARATOR, -1).length == 4;
}


/**
* Get the legacy subscribed service name for compatible with Dubbo 2.7.3 and below
*
Expand Down

0 comments on commit bce9641

Please sign in to comment.