Before Creating the Bug Report
Runtime platform environment
macOS (Darwin), reproduced with an isolated local unit test.
RocketMQ version
Branch: develop
Git commit: fd0c959
JDK Version
Zulu OpenJDK 8 (8.94.0.17)
Describe the Bug
MessageQueue.compareTo compares queue IDs by subtraction. For sufficiently distant int values, subtraction overflows and reverses the comparison sign, violating the Comparable contract.
Steps to Reproduce
- Create two MessageQueue objects with the same topic and broker.
- Use queue IDs Integer.MIN_VALUE and Integer.MAX_VALUE.
- Compare them in both directions.
- Observe that subtraction can produce the wrong sign.
What Did You Expect to See?
Queue IDs should be ordered according to their numeric value for the full int range.
What Did You See Instead?
Integer overflow can make a smaller queue ID compare as greater than a larger queue ID.
Additional Context
The behavior is reproducible without external services in MessageQueueTest.
Before Creating the Bug Report
Runtime platform environment
macOS (Darwin), reproduced with an isolated local unit test.
RocketMQ version
Branch: develop
Git commit: fd0c959
JDK Version
Zulu OpenJDK 8 (8.94.0.17)
Describe the Bug
MessageQueue.compareTo compares queue IDs by subtraction. For sufficiently distant int values, subtraction overflows and reverses the comparison sign, violating the Comparable contract.
Steps to Reproduce
What Did You Expect to See?
Queue IDs should be ordered according to their numeric value for the full int range.
What Did You See Instead?
Integer overflow can make a smaller queue ID compare as greater than a larger queue ID.
Additional Context
The behavior is reproducible without external services in MessageQueueTest.