[ISSUE #10782] Return error code for empty lock batch requests - #10790
[ISSUE #10782] Return error code for empty lock batch requests#10790Aias00 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR fixes #10782 by returning an explicit error code when a lock/unlock batch request contains an empty MessageQueue set, and adds unit tests to cover the behavior.
Changes:
- Set
ResponseCode.SYSTEM_ERRORforLOCK_BATCH_MQrequests with an emptymqSet. - Set
ResponseCode.SYSTEM_ERRORforUNLOCK_BATCH_MQrequests with an emptymqSet. - Add unit tests asserting the error code/remark and verifying the processor is not invoked.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivity.java | Adds an explicit response code for empty mqSet validation failures in lock/unlock batch handlers. |
| proxy/src/test/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivityTest.java | Adds tests to validate the new error response behavior for empty queue sets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Set<MessageQueue> mqSet = requestBody.getMqSet(); | ||
| if (mqSet.isEmpty()) { | ||
| response.setBody(requestBody.encode()); | ||
| response.setCode(ResponseCode.SYSTEM_ERROR); | ||
| response.setRemark("MessageQueue set is empty"); | ||
| return response; | ||
| } |
| Set<MessageQueue> mqSet = requestBody.getMqSet(); | ||
| if (mqSet.isEmpty()) { | ||
| response.setBody(requestBody.encode()); | ||
| response.setCode(ResponseCode.SYSTEM_ERROR); | ||
| response.setRemark("MessageQueue set is empty"); | ||
| return response; | ||
| } |
|
|
||
| @RunWith(MockitoJUnitRunner.class) | ||
| public class ConsumerManagerActivityTest extends InitConfigTest { | ||
| private static final String EMPTY_QUEUE_REMARK = "MessageQueue set is empty"; |
| RemotingCommand response = consumerManagerActivity.lockBatchMQ(null, request, null); | ||
|
|
||
| assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); | ||
| assertThat(response.getRemark()).isEqualTo(EMPTY_QUEUE_REMARK); |
| RemotingCommand response = consumerManagerActivity.unlockBatchMQ(null, request, null); | ||
|
|
||
| assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR); | ||
| assertThat(response.getRemark()).isEqualTo(EMPTY_QUEUE_REMARK); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10790 +/- ##
=============================================
- Coverage 48.34% 48.25% -0.10%
+ Complexity 13527 13493 -34
=============================================
Files 1380 1380
Lines 101104 101140 +36
Branches 13107 13120 +13
=============================================
- Hits 48882 48802 -80
- Misses 46267 46343 +76
- Partials 5955 5995 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What is changed
Why
Verification
Note: the local run completed with BUILD SUCCESS; it also printed existing JaCoCo 0.8.5 instrumentation warnings on the local JDK.