Just return empty instance list if service not found #1367

This commit is contained in:
IanCao 2019-06-14 17:40:33 +08:00
parent 0f72a349c5
commit 581e732305
2 changed files with 6 additions and 2 deletions

View File

@ -100,7 +100,7 @@ public class HostReactor {
public ServiceInfo processServiceJSON(String json) {
ServiceInfo serviceInfo = JSON.parseObject(json, ServiceInfo.class);
ServiceInfo oldService = serviceInfoMap.get(serviceInfo.getKey());
if (serviceInfo.getHosts() == null || !serviceInfo.validate()) {
if (serviceInfo.getHosts() == null || serviceInfo.getHosts().isEmpty() || !serviceInfo.validate()) {
//empty or error push, just ignore
return oldService;
}

View File

@ -373,7 +373,11 @@ public class InstanceController {
Service service = serviceManager.getService(namespaceId, serviceName);
if (service == null) {
throw new NacosException(NacosException.NOT_FOUND, "service not found: " + serviceName);
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("no instance to serve for service: " + serviceName);
}
result.put("hosts", new JSONArray());
return result;
}
checkIfDisabled(service);