Skip to content

[ISSUE #10782] Return error code for empty lock batch requests - #10790

Open
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-lock-unlock-empty-mq-code
Open

[ISSUE #10782] Return error code for empty lock batch requests#10790
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-lock-unlock-empty-mq-code

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What is changed

  • Set ResponseCode.SYSTEM_ERROR when remoting LOCK_BATCH_MQ or UNLOCK_BATCH_MQ receives an empty MessageQueue set.
  • Add unit coverage for both empty queue set paths.

Why

Verification

  • mvn -pl proxy -Dtest=ConsumerManagerActivityTest test

Note: the local run completed with BUILD SUCCESS; it also printed existing JaCoCo 0.8.5 instrumentation warnings on the local JDK.

Copilot AI review requested due to automatic review settings August 3, 2026 09:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ERROR for LOCK_BATCH_MQ requests with an empty mqSet.
  • Set ResponseCode.SYSTEM_ERROR for UNLOCK_BATCH_MQ requests with an empty mqSet.
  • 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.

Comment on lines 136 to 142
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;
}
Comment on lines 158 to 164
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-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.25%. Comparing base (eddb235) to head (beb3164).
⚠️ Report is 1 commits behind head on develop.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Proxy lock/unlock batch MQ returns response without error code for empty queue set

3 participants