diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java b/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java index e43dd6763..ddf194c36 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/core/HostReactor.java @@ -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; } diff --git a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java index 24a85f7f0..d4c75026f 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/controllers/InstanceController.java @@ -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);