Skip to content

Commit

Permalink
Merge 5e83579 into 2e7c1db
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 authored Feb 17, 2023
2 parents 2e7c1db + 5e83579 commit 736bfbd
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.annotations.VisibleForTesting;

public class MicroserviceVersions {
private static final Logger LOGGER = LoggerFactory.getLogger(MicroserviceVersions.class);

Expand Down Expand Up @@ -120,13 +122,18 @@ public String getShortName() {
return shortName;
}

@VisibleForTesting
public Map<String, MicroserviceVersion> getVersions() {
return versions;
synchronized (lock) {
return versions;
}
}

@SuppressWarnings("unchecked")
public <T extends MicroserviceVersion> T getVersion(String serviceId) {
return (T) versions.get(serviceId);
synchronized (lock) {
return (T) versions.get(serviceId);
}
}

public String getRevision() {
Expand Down Expand Up @@ -318,10 +325,11 @@ protected boolean isEventAccept(MicroserviceInstanceChangedEvent changedEvent) {
}

public void destroy() {
for (MicroserviceVersion microserviceVersion : versions.values()) {
microserviceVersion.destroy();
synchronized (lock) {
for (MicroserviceVersion microserviceVersion : versions.values()) {
microserviceVersion.destroy();
}
}

appManager.getEventBus().post(new DestroyMicroserviceEvent(this));
}
}

0 comments on commit 736bfbd

Please sign in to comment.