Skip to content

Commit f0fca7c

Browse files
committed
[#5141] fixed latest instance information cannot be obtained when cache instances is empty problem.
1 parent ed86d04 commit f0fca7c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

clients/service-center-client/src/main/java/org/apache/servicecomb/service/center/client/ServiceCenterDiscovery.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.servicecomb.service.center.client;
1919

20+
import java.util.ArrayList;
2021
import java.util.Collections;
2122
import java.util.List;
2223
import java.util.Map;
@@ -234,9 +235,15 @@ public void execute() {
234235
}
235236

236237
private synchronized void pullAllInstance() {
238+
List<SubscriptionKey> emptyInstancesCache = new ArrayList<>();
237239
instancesCache.forEach((k, v) -> {
238240
pullInstance(k, v, true);
241+
if (v.instancesCache.isEmpty()) {
242+
emptyInstancesCache.add(k);
243+
}
239244
});
245+
emptyInstancesCache.forEach(instancesCache::remove);
246+
emptyInstancesCache.clear();
240247
}
241248

242249
private static String instanceToString(List<MicroserviceInstance> instances) {

0 commit comments

Comments
 (0)