Aaron-He commented on a change in pull request #3475:
URL: https://github.com/apache/rocketmq/pull/3475#discussion_r751980767



##########
File path: 
remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java
##########
@@ -157,6 +162,9 @@ public static RemotingCommand rocketMQProtocolDecode(final 
byte[] headerArray) {
         // HashMap<String, String> extFields
         int extFieldsLength = headerBuffer.getInt();
         if (extFieldsLength > 0) {
+            if (extFieldsLength > headerArray.length) {

Review comment:
       > Would it be more appropriate to replace `headerArray.length` with 
`headerBuffer.capacity() - headerBuffer.position()`?
   
   `headerBuffer.capacity() - headerBuffer.position()` is more precise than 
`headerArray.length`.
   However, `headerBuffer.capacity() - headerBuffer.position()` has more 
subtraction operation than `headerArray.length`. Considering performance, 
`headerArray.length` may be more appropriate.




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