From 7519a53c521a8c600cd80f1d4ea76f66efd0eebb Mon Sep 17 00:00:00 2001 From: huangli Date: Fri, 10 Sep 2021 15:19:26 +0800 Subject: [PATCH] [ISSUE 3333] Remove commons-codes dependency (#3334) --- client/pom.xml | 4 ---- .../main/java/org/apache/rocketmq/client/trace/TraceView.java | 4 ++-- .../java/org/apache/rocketmq/client/trace/TraceViewTest.java | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index 9387eb3b..db5bb198 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -47,10 +47,6 @@ org.apache.commons commons-lang3 - - commons-codec - commons-codec - io.opentracing opentracing-api diff --git a/client/src/main/java/org/apache/rocketmq/client/trace/TraceView.java b/client/src/main/java/org/apache/rocketmq/client/trace/TraceView.java index e78d37ab..7601221c 100644 --- a/client/src/main/java/org/apache/rocketmq/client/trace/TraceView.java +++ b/client/src/main/java/org/apache/rocketmq/client/trace/TraceView.java @@ -17,9 +17,9 @@ package org.apache.rocketmq.client.trace; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.apache.commons.codec.Charsets; import org.apache.rocketmq.common.message.MessageExt; public class TraceView { @@ -40,7 +40,7 @@ public class TraceView { public static List decodeFromTraceTransData(String key, MessageExt messageExt) { List messageTraceViewList = new ArrayList(); - String messageBody = new String(messageExt.getBody(), Charsets.UTF_8); + String messageBody = new String(messageExt.getBody(), StandardCharsets.UTF_8); if (messageBody == null || messageBody.length() <= 0) { return messageTraceViewList; } diff --git a/client/src/test/java/org/apache/rocketmq/client/trace/TraceViewTest.java b/client/src/test/java/org/apache/rocketmq/client/trace/TraceViewTest.java index b1fdbaf9..0397db25 100644 --- a/client/src/test/java/org/apache/rocketmq/client/trace/TraceViewTest.java +++ b/client/src/test/java/org/apache/rocketmq/client/trace/TraceViewTest.java @@ -17,12 +17,12 @@ package org.apache.rocketmq.client.trace; -import org.apache.commons.codec.Charsets; import org.apache.rocketmq.common.message.MessageExt; import org.apache.rocketmq.common.message.MessageType; import org.junit.Assert; import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.util.List; public class TraceViewTest { @@ -46,7 +46,7 @@ public class TraceViewTest { .append(true).append(TraceConstants.FIELD_SPLITOR) .toString(); MessageExt message = new MessageExt(); - message.setBody(messageBody.getBytes(Charsets.UTF_8)); + message.setBody(messageBody.getBytes(StandardCharsets.UTF_8)); String key = "AC1415116D1418B4AAC217FE1B4E0000"; List traceViews = TraceView.decodeFromTraceTransData(key, message); Assert.assertEquals(traceViews.size(), 1); -- GitLab