GerardGao opened a new pull request, #10965:
URL: https://github.com/apache/rocketmq/pull/10965

   ### Which Issue(s) This PR Fixes
   
   - Fixes #10872
   
   ### Brief Description
   
   `HookUtils.transformTimerMessage` converted relative timer delays 
(`TIMER_DELAY_SEC` / `TIMER_DELAY_MS`) into an absolute delivery timestamp with 
unchecked `long` multiplication and addition. A very large delay such as 
`Long.MAX_VALUE` overflowed into a past timestamp, bypassed the future-delivery 
validation, and took the immediate-message path instead of being rejected.
   
   This change uses `Math.multiplyExact` / `Math.addExact` for the conversion. 
The existing `catch (Exception)` in the method turns the resulting 
`ArithmeticException` into `PutMessageStatus.WHEEL_TIMER_MSG_ILLEGAL`, so an 
unrepresentable delay is now rejected. It also snapshots 
`System.currentTimeMillis()` once per invocation so the conversion and the 
future-delivery check share the same time base.
   
   ### How Did You Test This Change?
   
   - New `HookUtilsTimerOverflowTest` with three cases:
     - `TIMER_DELAY_SEC = Long.MAX_VALUE` is rejected with 
`WHEEL_TIMER_MSG_ILLEGAL`;
     - `TIMER_DELAY_MS = Long.MAX_VALUE` is rejected with 
`WHEEL_TIMER_MSG_ILLEGAL`;
     - a delay that does not overflow but exceeds `timerMaxDelaySec` is still 
rejected (covers the future-delivery branch).
   - On the unfixed code the overflow cases fail (the message takes the 
immediate path); after the fix all three pass.
   - `mvn -pl broker -am test`: 763 tests, 0 failures (the single unrelated 
`BrokerOuterAPITest` error is a JDK 17 module-access issue in the test 
constructor, absent under the project's CI JDK 8).
   - New patch lines are fully covered by the added tests.
   


-- 
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]

Reply via email to