zzjcool opened a new issue, #8868:
URL: https://github.com/apache/rocketmq/issues/8868

   ### Before Creating the Bug Report
   
   - [X] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   
   - [X] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions)  of this 
repository and believe that this is not a duplicate.
   
   - [X] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   
   ### Runtime platform environment
   
   Linux Fedora
   
   ### RocketMQ version
   
   Git commit id: ecb45bb90dba46bb35b51520b01890c9c47ba55c
   
   ### JDK Version
   
   _No response_
   
   ### Describe the Bug
   
   
   **Description:**  
   The following message request codes exceed the maximum value for a short 
integer (32767), resulting in an overflow. The original values are as follows:
   
   ```java
   public static final int POP_MESSAGE = 200050;
   public static final int ACK_MESSAGE = 200051;
   public static final int BATCH_ACK_MESSAGE = 200151;
   public static final int PEEK_MESSAGE = 200052;
   public static final int CHANGE_MESSAGE_INVISIBLETIME = 200053;
   public static final int NOTIFICATION = 200054;
   public static final int POLLING_INFO = 200055;
   ```
   
   **Actual Values After Overflow:**  
   Due to the overflow, the actual values of these constants are:
   
   ```java
   public static final int POP_MESSAGE = 3442;
   public static final int ACK_MESSAGE = 3443;
   public static final int BATCH_ACK_MESSAGE = 3543;
   public static final int PEEK_MESSAGE = 3444;
   public static final int CHANGE_MESSAGE_INVISIBLETIME = 3445;
   public static final int NOTIFICATION = 3446;
   public static final int POLLING_INFO = 3447;
   ```
   
   **Proposed Solution:**  
   To prevent overflow, we need to ensure that all message codes remain within 
the valid range of short integers. Consider using values less than 32767 or 
refactoring the code to use a larger data type (e.g., `int` or `long`) if 
necessary.
   
   
   ### Steps to Reproduce
   
   rocketMQProtocolDecode code:
   
https://github.com/apache/rocketmq/blob/ecb45bb90dba46bb35b51520b01890c9c47ba55c/remoting/src/main/java/org/apache/rocketmq/remoting/protocol/RocketMQSerializable.java#L205C1-L209
   
   ### What Did You Expect to See?
   
   a short int
   
   ### What Did You See Instead?
   
    
   <img width="373" alt="image" 
src="https://github.com/user-attachments/assets/010961c1-928d-46e2-b746-505165439d09";>
   
   
   ### Additional Context
   
   _No response_


-- 
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: commits-unsubscr...@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to