From 62bf01ad5e638de71d77504d2e6a2db9dced8f09 Mon Sep 17 00:00:00 2001 From: HuangXin Date: Tue, 26 Jan 2021 08:59:11 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E4=BC=98=E5=8C=96Map?= =?UTF-8?q?=E9=81=8D=E5=8E=86=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ability/impl/DpTechBypassAbilityImpl.java | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java index eb7f1ff2..d0b1a5ea 100644 --- a/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java +++ b/src/main/java/com/dispose/ability/impl/DpTechBypassAbilityImpl.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -181,11 +182,16 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } // 清理缓存中的对象 - for (String v : disposeObjectCache.keySet()) { - if (disposeObjectCache.get(v).equals(objName)) { - disposeObjectCache.remove(v); + for (Map.Entry entry : disposeObjectCache.entrySet()) { + if (entry.getKey().equals(objName)) { + disposeObjectCache.remove(entry.getKey()); } } +// for (String v : disposeObjectCache.keySet()) { +// if (disposeObjectCache.get(v).equals(objName)) { +// disposeObjectCache.remove(v); +// } +// } return ErrorCode.ERR_OK; } @@ -484,8 +490,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } // 检查防护对象 - for (IpAddrType t : ipSegment.keySet()) { - String protectName = getProtectObjectName(v.getServiceId(), t); + for (Map.Entry entry : ipSegment.entrySet()) { + String protectName = getProtectObjectName(v.getServiceId(), entry.getKey()); // 防护对象存在 if (dpBypassManager.getProtectObject().containsKey(protectName)) { @@ -508,7 +514,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { boolean upgradeIpSegment = false; // 判断防护IP段是否有变化 - if (IpAddrType.IPV4.equals(t)) { + if (IpAddrType.IPV4.equals(entry.getKey())) { if (ipV4.size() != dp.getIpSegment().values().size()) { upgradeIpSegment = true; } else { @@ -520,7 +526,7 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { upgradeIpSegment = true; } } - } else if (IpAddrType.IPV6.equals(t)) { + } else if (IpAddrType.IPV6.equals(entry.getKey())) { if (ipV6.size() != dp.getIpSegment().values().size()) { upgradeIpSegment = true; } else { @@ -537,8 +543,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { // 更新防护对象 if (upgradeIpSegment) { err = upgradeProtectObject(protectName, - ipSegment.get(t), - IpAddrType.IPV4.equals(t) ? 0 : 1, + ipSegment.get(entry.getKey()), + IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1, template); if (err == ErrorCode.ERR_OK) { log.debug("upgrade Protection Object {} Succeed", protectName); @@ -548,8 +554,8 @@ public class DpTechBypassAbilityImpl extends DpTechAbilityImpl { } } else { err = createProtectObject(protectName, - ipSegment.get(t), - IpAddrType.IPV4.equals(t) ? 0 : 1, + ipSegment.get(entry.getKey()), + IpAddrType.IPV4.equals(entry.getKey()) ? 0 : 1, template); if (err == ErrorCode.ERR_OK) { log.debug("Add Protection Object {} Succeed", protectName);