Skip to content

Commit bbb2f90

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

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;
@@ -296,9 +297,15 @@ public void execute() {
296297
}
297298

298299
private synchronized void pullAllInstance() {
300+
List<SubscriptionKey> emptyInstancesCache = new ArrayList<>();
299301
instancesCache.forEach((k, v) -> {
300302
pullInstance(k, v, true);
303+
if (v.instancesCache.isEmpty()) {
304+
emptyInstancesCache.add(k);
305+
}
301306
});
307+
emptyInstancesCache.forEach(instancesCache::remove);
308+
emptyInstancesCache.clear();
302309
}
303310

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

0 commit comments

Comments
 (0)