joeCarf commented on code in PR #7367:
URL: https://github.com/apache/rocketmq/pull/7367#discussion_r1328055045


##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java:
##########
@@ -202,29 +202,33 @@ private static int calTotalLen(int remark, int ext) {
         return length;
     }
 
-    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
headerBuffer,
+    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
byteBuffer,
         int headerLen) throws RemotingCommandException {
         RemotingCommand cmd = new RemotingCommand();
+        int beginIndex = byteBuffer.readerIndex();
         // int code(~32767)
-        cmd.setCode(headerBuffer.readShort());
+        cmd.setCode(byteBuffer.readShort());
         // LanguageCode language
-        cmd.setLanguage(LanguageCode.valueOf(headerBuffer.readByte()));
+        cmd.setLanguage(LanguageCode.valueOf(byteBuffer.readByte()));
         // int version(~32767)
-        cmd.setVersion(headerBuffer.readShort());
+        cmd.setVersion(byteBuffer.readShort());
         // int opaque
-        cmd.setOpaque(headerBuffer.readInt());
+        cmd.setOpaque(byteBuffer.readInt());
         // int flag
-        cmd.setFlag(headerBuffer.readInt());
+        cmd.setFlag(byteBuffer.readInt());
+        // remain length
+        int remainLength = headerLen - byteBuffer.readerIndex() + beginIndex;

Review Comment:
   引入一个新的变量,似乎增加了复杂性



##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java:
##########
@@ -202,29 +202,33 @@ private static int calTotalLen(int remark, int ext) {
         return length;
     }
 
-    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
headerBuffer,
+    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
byteBuffer,

Review Comment:
   修改命名以后`headerLen`和`byteBuffer`似乎没有对应关系



##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java:
##########
@@ -202,29 +202,33 @@ private static int calTotalLen(int remark, int ext) {
         return length;
     }
 
-    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
headerBuffer,
+    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
byteBuffer,
         int headerLen) throws RemotingCommandException {
         RemotingCommand cmd = new RemotingCommand();
+        int beginIndex = byteBuffer.readerIndex();
         // int code(~32767)
-        cmd.setCode(headerBuffer.readShort());
+        cmd.setCode(byteBuffer.readShort());
         // LanguageCode language
-        cmd.setLanguage(LanguageCode.valueOf(headerBuffer.readByte()));
+        cmd.setLanguage(LanguageCode.valueOf(byteBuffer.readByte()));
         // int version(~32767)
-        cmd.setVersion(headerBuffer.readShort());
+        cmd.setVersion(byteBuffer.readShort());
         // int opaque
-        cmd.setOpaque(headerBuffer.readInt());
+        cmd.setOpaque(byteBuffer.readInt());
         // int flag
-        cmd.setFlag(headerBuffer.readInt());
+        cmd.setFlag(byteBuffer.readInt());
+        // remain length
+        int remainLength = headerLen - byteBuffer.readerIndex() + beginIndex;

Review Comment:
   引入一个新的变量,似乎增加了复杂性



##########
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java:
##########
@@ -202,29 +202,33 @@ private static int calTotalLen(int remark, int ext) {
         return length;
     }
 
-    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
headerBuffer,
+    public static RemotingCommand rocketMQProtocolDecode(final ByteBuf 
byteBuffer,

Review Comment:
   修改命名以后`headerLen`和`byteBuffer`似乎没有对应关系



-- 
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