Skip to content

[ISSUE #10778] Skip empty priority queue groups - #10779

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-penalizer-empty-priority-group
Open

[ISSUE #10778] Skip empty priority queue groups#10779
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-penalizer-empty-priority-group

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What changed

  • Skip empty priority groups when selecting the least-penalty message queue.
  • Return null when all priority groups are empty, matching the existing selectLeastPenalty() empty-list contract.
  • Add regression coverage for both all-empty and partially-empty priority group inputs.

Fixes #10778.

Verification

mvn -pl proxy -Dtest=MessageQueuePenalizerTest test

Result: BUILD SUCCESS. MessageQueuePenalizerTest ran 23 tests with 0 failures, errors, or skips. Checkstyle and SpotBugs also passed in the Maven run.

Copilot AI review requested due to automatic review settings August 3, 2026 07:04

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

Fixes a robustness bug in Proxy route queue selection by making MessageQueuePenalizer.selectLeastPenaltyWithPriority() tolerate empty priority buckets and match the existing “empty input => null” contract used by selectLeastPenalty().

Changes:

  • Skip empty (and null) priority groups when scanning for the least-penalty queue.
  • Return null when all priority groups are empty (instead of returning a (null, Integer.MAX_VALUE) pair / throwing).
  • Add regression tests covering all-empty and partially-empty priority group inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
proxy/src/main/java/org/apache/rocketmq/proxy/service/route/MessageQueuePenalizer.java Skips empty priority buckets and returns null when no queue can be selected.
proxy/src/test/java/org/apache/rocketmq/proxy/service/route/MessageQueuePenalizerTest.java Adds tests to prevent regressions for empty priority-group handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.24%. Comparing base (eddb235) to head (8eebdac).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop   #10779   +/-   ##
==========================================
  Coverage      48.24%   48.24%           
- Complexity     13496    13497    +1     
==========================================
  Files           1380     1380           
  Lines         101104   101108    +4     
  Branches       13107    13109    +2     
==========================================
+ Hits           48773    48779    +6     
+ Misses         46350    46347    -3     
- Partials        5981     5982    +1     

☔ 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.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Adds null/empty guard for the selected queue in DefaultConsumerGroupAssignor.assign(), preventing NullPointerException when selectLeastPenalty() returns null or when all priority groups are empty.

Findings

  • [Info] The fix correctly handles the case where all queue groups are empty or selectLeastPenalty() returns null. The null check on bestQueue at the end prevents NPE when no valid queue is found.
  • [Info] The removal of double spaces (if (queueAndPenalty == null)) is a good minor cleanup.
  • [Info] Test coverage is solid — testAssignAllEmptyPriorityGroups verifies the FORBIDDEN result, and testAssignPartialEmptyPriorityGroups verifies partial-empty scenarios still work.

Suggestions

  • Minor: the if (bestQueue == null) check at the end could include a brief inline comment explaining that this handles the "all groups empty" case for future readers.

LGTM.


Automated review by github-manager-bot

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] MessageQueuePenalizer throws when a priority group is empty

4 participants