From 8cedd077e0df968a4f5eeedd85efcd71bf48aae2 Mon Sep 17 00:00:00 2001 From: felixgis14 <71480844+felixgis14@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:37:47 +0800 Subject: [PATCH] [SCB-2895]The findServices method returns data errors (#4674) --- .../servicecomb/registry/consul/ConsulDiscovery.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/service-registry/registry-consul/src/main/java/org/apache/servicecomb/registry/consul/ConsulDiscovery.java b/service-registry/registry-consul/src/main/java/org/apache/servicecomb/registry/consul/ConsulDiscovery.java index 855f2348fd7..c8229ad9ca5 100644 --- a/service-registry/registry-consul/src/main/java/org/apache/servicecomb/registry/consul/ConsulDiscovery.java +++ b/service-registry/registry-consul/src/main/java/org/apache/servicecomb/registry/consul/ConsulDiscovery.java @@ -84,8 +84,11 @@ public List findServiceInstances(String application, St @Override public List findServices(String application) { LOGGER.info("ConsulDiscovery findServices(application={})", application); - Map services = consulClient.agentClient().getServices(); - return Lists.newArrayList(services.keySet()); + Map> response = consulClient.catalogClient().getServices().getResponse(); + if (!CollectionUtils.isEmpty(response)) { + return Lists.newArrayList(response.keySet()); + } + return Lists.newArrayList(); } @Override