yuluo-yx opened a new issue, #10874: URL: https://github.com/apache/rocketmq/issues/10874
### Before Creating the Bug Report - [x] I found a bug, not just a question. - [x] I searched open GitHub Issues and pull requests and found no duplicate. - [x] I confirmed that this bug belongs to Apache RocketMQ. ### Runtime platform environment macOS (Darwin), reproduced with an isolated local unit test. ### RocketMQ version Branch: develop Git commit: fd0c95920e0deac96ce2ae27442747cc5e65e930 ### 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 1. Create two MessageQueue objects with the same topic and broker. 2. Use queue IDs Integer.MIN_VALUE and Integer.MAX_VALUE. 3. Compare them in both directions. 4. 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. -- 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]
