[ISSUE #10770] Skip queryAssignment queues without master broker - #10771
[ISSUE #10770] Skip queryAssignment queues without master broker#10771Aias00 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Proxy gRPC RouteActivity#queryAssignment against malformed/partial route metadata by skipping queue rows that don’t have a master broker entry, avoiding exceptional failures during protobuf MessageQueue construction and instead returning the existing controlled FORBIDDEN response when no valid assignments remain.
Changes:
- Skip queue rows where
brokerIdMap.get(MixAll.MASTER_ID)returnsnullinRouteActivity#queryAssignment. - Add a regression test covering route metadata that only contains non-master broker IDs.
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/grpc/v2/route/RouteActivity.java | Skips queue rows lacking a master broker to prevent null broker usage when building assignments. |
| proxy/src/test/java/org/apache/rocketmq/proxy/grpc/v2/route/RouteActivityTest.java | Adds coverage for the “missing master broker” route-metadata scenario, asserting a controlled FORBIDDEN response with no assignments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10771 +/- ##
=============================================
- Coverage 48.24% 48.23% -0.01%
+ Complexity 13496 13492 -4
=============================================
Files 1380 1380
Lines 101104 101106 +2
Branches 13107 13108 +1
=============================================
- Hits 48773 48770 -3
- Misses 46350 46354 +4
- Partials 5981 5982 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Adds null check for broker after brokerIdMap.get(MixAll.MASTER_ID) in DefaultConsumerAssignor.queryAssignment(), preventing NullPointerException when the master broker is missing from the route result.
Findings
- [Info] The fix is correct and minimal. Returning a FORBIDDEN result when the master broker is unavailable is the right behavior — the client should not proceed with assignment from an incomplete route.
- [Info] Test coverage verifies that a missing master broker results in FORBIDDEN with no assignments.
Suggestions
- None. Clean, targeted fix.
LGTM.
Automated review by github-manager-bot
What changed
This PR makes Proxy gRPC
RouteActivity#queryAssignmentskip queue rows that do not have a master broker entry in the broker map.Previously, the code passed a possibly-null master
Brokerinto the protobufMessageQueuebuilder, which could fail the request exceptionally when route metadata only had non-master broker ids.Why
Malformed or partial route metadata should produce a controlled assignment response. If no valid assignment can be built after skipping invalid rows, the existing
FORBIDDEN/no readable queueresponse is returned.Fixes #10770.
Verification
mvn -pl proxy -Dtest=RouteActivityTest testResult: BUILD SUCCESS.
RouteActivityTestran 8 tests with 0 failures/errors/skips. Checkstyle and SpotBugs also passed in the Maven run.