From 064d4c33d299f653c480c79acc666d5c3608b3de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=98=B3?= <1727611626@qq.com> Date: Wed, 29 Jul 2020 15:27:06 +0800 Subject: [PATCH] [ISSUE#2176] Fix the issue of redundancy parameters in method --- .../org/apache/rocketmq/acl/common/AclUtils.java | 2 +- .../acl/plain/RemoteAddressStrategyFactory.java | 2 +- .../org/apache/rocketmq/acl/common/AclUtilsTest.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java b/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java index c4847239..77abe0e8 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/common/AclUtils.java @@ -94,7 +94,7 @@ public class AclUtils { } } - public static String v6ipProcess(String netaddress, String[] strArray, int index) { + public static String v6ipProcess(String netaddress) { int part; String subAddress; boolean isAsterisk = isAsterisk(netaddress); diff --git a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java index 242c98d6..8db0fda9 100644 --- a/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java +++ b/acl/src/main/java/org/apache/rocketmq/acl/plain/RemoteAddressStrategyFactory.java @@ -153,7 +153,7 @@ public class RemoteAddressStrategyFactory { for (int i = 1; i < strArray.length; i++) { if (ipv6Analysis(strArray, i)) { AclUtils.verify(remoteAddr, index - 1); - String preAddress = AclUtils.v6ipProcess(remoteAddr, strArray, index); + String preAddress = AclUtils.v6ipProcess(remoteAddr); this.index = StringUtils.split(preAddress, ":").length; this.head = preAddress; break; diff --git a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java index d1fdcb66..7df0afa6 100644 --- a/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java +++ b/acl/src/test/java/org/apache/rocketmq/acl/common/AclUtilsTest.java @@ -181,19 +181,23 @@ public class AclUtilsTest { public void v6ipProcessTest() { String remoteAddr = "5::7:6:1-200:*"; String[] strArray = StringUtils.split(remoteAddr, ":"); - Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0007:0006"); + Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr), "0005:0000:0000:0000:0007:0006"); +// Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0007:0006"); remoteAddr = "5::7:6:1-200"; strArray = StringUtils.split(remoteAddr, ":"); - Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006"); + Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr), "0005:0000:0000:0000:0000:0007:0006"); +// Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006"); remoteAddr = "5::7:6:*"; strArray = StringUtils.split(remoteAddr, ":"); - Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006"); + Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr), "0005:0000:0000:0000:0000:0007:0006"); +// Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0000:0000:0000:0000:0007:0006"); remoteAddr = "5:7:6:*"; strArray = StringUtils.split(remoteAddr, ":"); - Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0007:0006"); + Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr), "0005:0007:0006"); +// Assert.assertEquals(AclUtils.v6ipProcess(remoteAddr, strArray, 3), "0005:0007:0006"); } @Test -- GitLab