From 42878a29e0e6a66078b80cf01d48bd05035bdcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=B8=8D=E7=9F=A5=E5=90=8D=E7=9A=84Java?= =?UTF-8?q?=E9=9D=93=E4=BB=94?= <42876375+icodening@users.noreply.github.com> Date: Tue, 15 Mar 2022 10:57:46 +0800 Subject: [PATCH] dashboard: Fix the bug that removing token servers may fail when there are servers with the same IP (#2591) --- .../csp/sentinel/dashboard/util/ClusterEntityUtils.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java index ced801fa..791be13c 100644 --- a/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java +++ b/sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/util/ClusterEntityUtils.java @@ -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)