Fix can't query non-default-group problem for catalog API (#4502)

This commit is contained in:
杨翊 SionYang 2020-12-16 17:28:36 +08:00 committed by GitHub
parent 617c5e16b1
commit 7d9c103f0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,8 +62,7 @@ public class CatalogServiceV2Impl implements CatalogService {
@Override
public Object getServiceDetail(String namespaceId, String groupName, String serviceName) throws NacosException {
Service service = Service.newService(namespaceId, NamingUtils.getGroupName(serviceName),
NamingUtils.getServiceName(serviceName));
Service service = Service.newService(namespaceId, groupName, serviceName);
if (!ServiceManager.getInstance().containSingleton(service)) {
throw new NacosException(NacosException.NOT_FOUND,
String.format("service %s@@%s is not found!", groupName, serviceName));
@ -73,8 +72,8 @@ public class CatalogServiceV2Impl implements CatalogService {
ServiceMetadata detailedService = metadata.orElseGet(ServiceMetadata::new);
ObjectNode serviceObject = JacksonUtils.createEmptyJsonNode();
serviceObject.put("name", NamingUtils.getServiceName(serviceName));
serviceObject.put("groupName", NamingUtils.getGroupName(serviceName));
serviceObject.put("name", serviceName);
serviceObject.put("groupName", groupName);
serviceObject.put("protectThreshold", detailedService.getProtectThreshold());
serviceObject.replace("selector", JacksonUtils.transferToJsonNode(detailedService.getSelector()));
serviceObject.replace("metadata", JacksonUtils.transferToJsonNode(detailedService.getExtendData()));