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

   ### Motivation
   
   `AckMessageActivity.ackMessage` inspects the first entry before checking 
that any entry exists:
   
   ```java
   boolean isBatchAck = ConfigurationManager.getProxyConfig().isEnableBatchAck()
       && !request.getEntries(0).hasLiteTopic();
   ```
   
   An `AckMessageRequest` whose `entries` list is empty (nothing in the 
protobuf schema forbids it) therefore throws `IndexOutOfBoundsException` from 
`getEntries(0)` when `enableBatchAck` is on, which the catch block wraps into 
the future as a raw `Throwable` — the gRPC client receives an opaque internal 
error instead of a meaningful status.
   
   ### Modifications
   
   - Guard `request.getEntriesCount() == 0` before the batch-ack decision and 
throw `GrpcProxyException(Code.BAD_REQUEST, "ack entries should not be 
empty")`, the same input-validation pattern used by `SendMessageActivity` (e.g. 
max recovery time / delivery timestamp checks).
   
   ### Verification
   
   Fail-before (new test on unpatched code, with `enableBatchAck=true`): the 
future completes exceptionally with the `IndexOutOfBoundsException`, so the 
assertion on `GrpcProxyException`/`Code.BAD_REQUEST` fails:
   
   ```
   AckMessageActivityTest.testAckMessageWithEmptyEntries:84 » AssertionError
   ```
   
   Pass-after — full `AckMessageActivityTest` (2 existing + 1 new):
   
   ```
   mvn -pl proxy test -Dtest='AckMessageActivityTest'
   Tests run: 3, 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]

Reply via email to