zjncs opened a new pull request, #11099: URL: https://github.com/apache/rocketmq/pull/11099
### Motivation `maxNum` reaches `IndexService.queryOffset` straight from `QueryMessageRequestHeader`, where the field is only annotated `@CFNotNull` — no range validation. A negative value therefore survives the existing ```java maxNum = Math.min(maxNum, this.defaultMessageStore.getMessageStoreConfig().getMaxMsgsNumBatch()); List<Long> phyOffsets = new ArrayList<>(maxNum); ``` cap (min of a negative and a positive is still negative) and `new ArrayList<>(maxNum)` throws `IllegalArgumentException: Illegal Capacity: -1` *before* the `try` block, so it propagates uncaught through `DefaultMessageStore.queryMessage` back to the request processor, answering the client with an opaque `SYSTEM_ERROR`. ### Modifications - Clamp `maxNum` to a minimum of 0 before the cap: `Math.min(Math.max(maxNum, 0), maxMsgsNumBatch)`. A negative request now simply returns an empty `QueryOffsetResult`, consistent with `maxNum == 0`. ### Verification Fail-before (new test on unpatched code): ``` IndexServiceTest.testQueryOffsetWithNegativeMaxNum:87 » IllegalArgument Illegal Capacity: -1 ``` Pass-after — full `IndexServiceTest` (5 existing + 1 new): ``` mvn -pl store test -Dtest='IndexServiceTest' Tests run: 6, Failures: 0, Errors: 0, Skipped: 0 ``` -- 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]
