liubao68 commented on a change in pull request #2578:
URL:
https://github.com/apache/servicecomb-java-chassis/pull/2578#discussion_r708220320
##########
File path:
foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/consumer/MicroserviceManager.java
##########
@@ -60,8 +60,8 @@ public MicroserviceVersions
getOrCreateMicroserviceVersions(String microserviceN
microserviceVersions = versionsByName.get(microserviceName);
if (microserviceVersions == null) {
microserviceVersions = new MicroserviceVersions(appManager, appId,
microserviceName);
- microserviceVersions.pullInstances();
versionsByName.put(microserviceName, microserviceVersions);
+ microserviceVersions.pullInstances();
Review comment:
Maybe you can add a synchronized to `pullInstances` and
`onMicroserviceInstanceChanged` can solve this problem.
And your modification seems not correct and may cause some other concurent
problems and add add a cyclic dependency between foundation-registry and
registry-service-center.
```
public void pullInstances() {
for (MicroserviceVersions microserviceVersions :
versionsByName.values()) {
microserviceVersions.pullInstances();
tryRemoveInvalidMicroservice(microserviceVersions);
}
}
public void onMicroserviceInstanceChanged(MicroserviceInstanceChangedEvent
changedEvent) {
for (MicroserviceVersions microserviceVersions :
versionsByName.values()) {
microserviceVersions.onMicroserviceInstanceChanged(changedEvent);
tryRemoveInvalidMicroservice(microserviceVersions);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]