This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new e47e3cdbb [ISSUE #5996] Optimize the RemotingSerializable class code 
(#5998)
e47e3cdbb is described below

commit e47e3cdbb532b6862f6ce9a5c36fb43bed12ae47
Author: hardyfish <[email protected]>
AuthorDate: Wed Feb 8 09:55:39 2023 +0800

    [ISSUE #5996] Optimize the RemotingSerializable class code (#5998)
    
    * simplified RemotingSerializable null check
    
    * optimize the RemotingSerializable class code
---
 .../apache/rocketmq/remoting/protocol/RemotingSerializable.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
 
b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
index c49546d62..60cc4e3e2 100644
--- 
a/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
+++ 
b/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RemotingSerializable.java
@@ -26,11 +26,11 @@ public abstract class RemotingSerializable {
     private final static Charset CHARSET_UTF8 = StandardCharsets.UTF_8;
 
     public static byte[] encode(final Object obj) {
-        final String json = toJson(obj, false);
-        if (json != null) {
-            return json.getBytes(CHARSET_UTF8);
+        if (obj == null) {
+            return null;
         }
-        return null;
+        final String json = toJson(obj, false);
+        return json.getBytes(CHARSET_UTF8);
     }
 
     public static String toJson(final Object obj, boolean prettyFormat) {

Reply via email to