dashboard: Fix the bug that removing token servers may fail when there are servers with the same IP (#2591)

This commit is contained in:
一个不知名的Java靓仔 2022-03-15 10:57:46 +08:00 committed by GitHub
parent 0cd06291f3
commit 42878a29e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -130,7 +130,8 @@ public final class ClusterEntityUtils {
if (mode == ClusterStateManager.CLUSTER_SERVER) {
String serverAddress = getIp(ip);
int port = stateVO.getState().getServer().getPort();
map.computeIfAbsent(serverAddress, v -> new ClusterGroupEntity()
String targetAddress = serverAddress + ":" + port;
map.computeIfAbsent(targetAddress, v -> new ClusterGroupEntity()
.setBelongToApp(true).setMachineId(ip + '@' + stateVO.getCommandPort())
.setIp(ip).setPort(port)
);
@ -145,8 +146,8 @@ public final class ClusterEntityUtils {
if (StringUtil.isBlank(targetServer) || targetPort == null || targetPort <= 0) {
continue;
}
ClusterGroupEntity group = map.computeIfAbsent(targetServer,
String targetAddress = targetServer + ":" + targetPort;
ClusterGroupEntity group = map.computeIfAbsent(targetAddress,
v -> new ClusterGroupEntity()
.setBelongToApp(true).setMachineId(targetServer)
.setIp(targetServer).setPort(targetPort)