Skip to content

[Bug] Request Code overflow #8868

@zzjcool

Description

@zzjcool

Before Creating the Bug Report

  • I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • 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: ecb45bb

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:

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:

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?

image

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions