yuz10 commented on code in PR #10162:
URL: https://github.com/apache/rocketmq/pull/10162#discussion_r2924391368


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java:
##########
@@ -45,31 +44,22 @@ public static <T> T decode(final byte[] data, Class<T> 
classOfT) {
         if (data == null) {
             return null;
         }
-        return fromJson(data, classOfT);
+        return JSON.parseObject(data, classOfT);
     }
 
     public static <T> List<T> decodeList(final byte[] data, Class<T> classOfT) 
{
         if (data == null) {
             return null;
         }
-        String json = new String(data, CHARSET_UTF8);
-        return JSON.parseArray(json, classOfT);
+        return JSON.parseArray(data, 0, data.length, CHARSET_UTF8, classOfT);
     }
 
     public static <T> T fromJson(String json, Class<T> classOfT) {
         return JSON.parseObject(json, classOfT);
     }
 
-    private static <T> T fromJson(byte[] data, Class<T> classOfT) {
-        return JSON.parseObject(data, classOfT);
-    }
-
     public byte[] encode() {
-        final String json = this.toJson();
-        if (json != null) {
-            return json.getBytes(CHARSET_UTF8);
-        }
-        return null;
+        return JSON.toJSONBytes(this);

Review Comment:
   JSON.toJSONBytes(this, StandardCharsets.UTF_8)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to