duhenglucky commented on a change in pull request #1758: Fix bug in 
MessageClientIDSetter
URL: https://github.com/apache/rocketmq/pull/1758#discussion_r378026223
 
 

 ##########
 File path: 
common/src/main/java/org/apache/rocketmq/common/message/MessageClientIDSetter.java
 ##########
 @@ -37,13 +37,10 @@
         } catch (Exception e) {
             ip = createFakeIP();
         }
-        LEN = ip.length + 2 + 4 + 4 + 2;
-        ByteBuffer tempBuffer = ByteBuffer.allocate(ip.length + 2 + 4);
-        tempBuffer.position(0);
+        LEN = ip.length + 4 + 4 + 4 + 2;
+        ByteBuffer tempBuffer = ByteBuffer.allocate(ip.length + 4 + 4);
         tempBuffer.put(ip);
-        tempBuffer.position(ip.length);
         tempBuffer.putInt(UtilAll.getPid());
-        tempBuffer.position(ip.length + 2);
 
 Review comment:
   pid is short,so maybe putShort can resolve this issue,and this indeed a bug, 
ip.length + 2 will keep the lower 2 bytes. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to