From f1e60cb06cf9af07617fa0b15dec81f67738f0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8D=E7=BC=96=E8=AF=91=E5=B7=A5=E4=BD=9C=E5=8C=BA?= Date: Sat, 25 Apr 2026 00:16:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(v0.11):=20=E7=AC=AC=E5=85=AD=E8=BD=AE?= =?UTF-8?q?=E8=B5=B0=E6=9F=A5=E2=80=94=E2=80=94legacy=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=20System.out=20=E6=BC=94=E7=A4=BA=E5=85=A5=E5=8F=A3=E4=B8=8E?= =?UTF-8?q?=20Kafka=20=E6=B6=88=E8=B4=B9=E7=AB=AF=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AESUtils / RSAUtils / SM4Utils / CustomXssUtil / SnowFlakeSerialCode:删除仅用于本地演示的 main,消除生产源码中的 System.out。 - KafkaConsumer:移除 printStackTrace;异常改为 logger.error(msg, e);Class.newInstance 改为 getDeclaredConstructor().newInstance()。 对应 docs/reviews 05 工程卫生项;全量 maven-cloudwalk-legacy-public 已通过 compile。 Made-with: Cursor Former-commit-id: 2d9fa1c9ded45723f87df28a4c51134f182cb895 --- .../cn/cloudwalk/cloud/security/AESUtils.java | 13 ----------- .../cn/cloudwalk/cloud/security/RSAUtils.java | 10 -------- .../cn/cloudwalk/cloud/security/SM4Utils.java | 5 ---- .../serial/worker/SnowFlakeSerialCode.java | 23 ------------------- .../cloudwalk/web/xss/util/CustomXssUtil.java | 4 ---- .../client/event/consumer/KafkaConsumer.java | 19 ++++++++------- 6 files changed, 9 insertions(+), 65 deletions(-) diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/AESUtils.java b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/AESUtils.java index 10d15840..52f93e97 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/AESUtils.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/AESUtils.java @@ -1,7 +1,6 @@ package cn.cloudwalk.cloud.security; import java.nio.charset.Charset; -import java.util.Arrays; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Base64; @@ -148,18 +147,6 @@ throw new IllegalArgumentException("encode init error"); } } - -public static void main(String[] args) throws Exception { -byte[] bytes1 = { 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 }; -System.out.println("原数组长度:-----" + bytes1.length); -byte[] bytes = getEncCode(bytes1, "123asdasdasdas21"); -System.out.println("加密后长度:-----" + bytes.length); -System.out.println(Arrays.toString(bytes)); - -byte[] bytes2 = getDecCode(bytes, "123asdasdasdas21"); -System.out.println("还原数组长度:-----" + bytes2.length); -System.out.println(Arrays.toString(bytes2)); -} } diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/RSAUtils.java b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/RSAUtils.java index 26413fca..2f6b19ad 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/RSAUtils.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/RSAUtils.java @@ -224,16 +224,6 @@ signature.update(data); return signature.verify(Base64.decodeBase64(sign)); } - -public static void main(String[] args) throws Exception { -Map map = initKey(); - -String str = "这是一段测试报文"; -byte[] ret = encryptByPublic(str.getBytes("utf-8"), getPublicKey(map)); -System.out.println(Base64.encodeBase64String(ret)); - -System.out.println(new String(decryptByPrivate(ret, getPrivateKey(map)), "utf-8")); -} } diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/SM4Utils.java b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/SM4Utils.java index 4e9a5384..a804c9cb 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/SM4Utils.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-result/src/main/java/cn/cloudwalk/cloud/security/SM4Utils.java @@ -382,11 +382,6 @@ sms4(ciphertext, 16, key, plain, 0); return plain; } - -public static void main(String[] args) throws Exception { -System.out.println(encodeSMS4("1aaaa", "465535453546785465342345")); -System.out.println(decodeSMS4(encodeSMS4("1aaaa", "465535453546785465342345"), "465535453546785465342345")); -} } diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/worker/SnowFlakeSerialCode.java b/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/worker/SnowFlakeSerialCode.java index dca243f7..58366731 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/worker/SnowFlakeSerialCode.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-serial/src/main/java/cn/cloudwalk/serial/worker/SnowFlakeSerialCode.java @@ -279,29 +279,6 @@ this.workId = workId; } } -public static void main(String[] args) throws Exception { -Enumeration en = NetworkInterface.getNetworkInterfaces(); -StringBuilder sb = new StringBuilder(); -ArrayList tmpMacList = new ArrayList<>(); -while (en.hasMoreElements()) { -NetworkInterface iface = en.nextElement(); -List addrs = iface.getInterfaceAddresses(); -for (InterfaceAddress addr : addrs) { -InetAddress ip = addr.getAddress(); -NetworkInterface network = NetworkInterface.getByInetAddress(ip); -if (network == null) -continue; byte[] mac = network.getHardwareAddress(); -if (mac == null) -continue; sb.delete(0, sb.length()); -for (int i = 0; i < mac.length; ) { sb.append(String.format("%02X%s", new Object[] { Byte.valueOf(mac[i]), (i < mac.length - 1) ? "-" : "" })); i++; } -tmpMacList.add(sb.toString()); -} -} if (tmpMacList.size() <= 0) { -System.out.println("mac地址列表为空"); -} -for (String mac : tmpMacList) -System.out.println(mac); -} } diff --git a/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/xss/util/CustomXssUtil.java b/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/xss/util/CustomXssUtil.java index 18dc57df..69f04e06 100644 --- a/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/xss/util/CustomXssUtil.java +++ b/maven-cloudwalk-legacy-public/cloudwalk-common-web/src/main/java/cn/cloudwalk/web/xss/util/CustomXssUtil.java @@ -133,10 +133,6 @@ value = ONLOAD_PATTERN.matcher(value).replaceAll(""); return value; } - -public static void main(String[] args) { -System.out.println(stripXSS("\\\">")); -} } diff --git a/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/consumer/KafkaConsumer.java b/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/consumer/KafkaConsumer.java index 0eac6ee4..a3fb4be2 100644 --- a/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/consumer/KafkaConsumer.java +++ b/maven-cloudwalk-legacy-public/cwos-sdk-event/src/main/java/cn/cloudwalk/cwos/client/event/consumer/KafkaConsumer.java @@ -150,7 +150,8 @@ if (this.eventListener == null) { Reflections reflections = new Reflections(new Object[0]); Set> subTypes = reflections.getSubTypesOf(EventListener.class); if (subTypes.size() == 1) { -EventListener eventListener = ((Class)subTypes.iterator().next()).newInstance(); +EventListener eventListener = + ((Class)subTypes.iterator().next()).getDeclaredConstructor().newInstance(); this.eventListener = eventListener; pullThread(); } else { @@ -161,13 +162,12 @@ pullThread(); } } else { if (this.eventListener == null) { -this.eventListener = this.listenerClass.newInstance(); +this.eventListener = this.listenerClass.getDeclaredConstructor().newInstance(); } pullThread(); } } catch (Exception e) { -e.printStackTrace(); -this.logger.error(e.getMessage()); +this.logger.error("KafkaConsumer.pull 初始化失败", e); } } @@ -179,7 +179,8 @@ if (this.eventListener == null) { Reflections reflections = new Reflections(new Object[0]); Set> subTypes = reflections.getSubTypesOf(EventListener.class); if (subTypes.size() == 1) { -EventListener eventListener = ((Class)subTypes.iterator().next()).newInstance(); +EventListener eventListener = + ((Class)subTypes.iterator().next()).getDeclaredConstructor().newInstance(); this.eventListener = eventListener; } else { throw new NoneClassImplementsException("none class or than one"); @@ -189,12 +190,11 @@ pullThread(); } } else if (this.eventListener == null) { -this.eventListener = this.listenerClass.newInstance(); +this.eventListener = this.listenerClass.getDeclaredConstructor().newInstance(); } } catch (Exception e) { -e.printStackTrace(); -this.logger.error(e.getMessage()); +this.logger.error("KafkaConsumer.initListener 失败", e); } } @@ -204,8 +204,7 @@ try { this.eventListeners.put(eventType.getCode(), eventSingleSubEventListener); pullThread(); } catch (Exception e) { -e.printStackTrace(); -this.logger.error(e.getMessage()); +this.logger.error("KafkaConsumer.pull(eventType) 失败", e); } }