diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/DiscoveryManager.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/DiscoveryManager.java index 256b392de2..2cbe83a246 100644 --- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/DiscoveryManager.java +++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/DiscoveryManager.java @@ -93,10 +93,6 @@ private void onInstancesChanged(String application, String serviceName, private void onInstancesChanged(String registryName, String application, String serviceName, List instances) { - for (InstanceChangeListener listener : this.instanceChangeListeners) { - listener.onInstancesChanged(registryName, application, serviceName, instances); - } - Map statefulInstances = allInstances.computeIfAbsent(application, key -> new ConcurrentHashMapEx<>()).computeIfAbsent(serviceName, key -> new ConcurrentHashMapEx<>()); @@ -136,6 +132,10 @@ private void onInstancesChanged(String registryName, String application, String application, serviceName, instances.size(), instanceInfo); rebuildVersionCache(application, serviceName); + + for (InstanceChangeListener listener : this.instanceChangeListeners) { + listener.onInstancesChanged(registryName, application, serviceName, instances); + } } public void addInstanceChangeListener(InstanceChangeListener instanceChangeListener) {