[ISSUE #10772] Skip malformed current broker data - #10773
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens DefaultAdminService#createTopicOnBroker in the proxy module to tolerate malformed “current broker” route entries, preventing an NPE when current BrokerData rows are missing brokerAddrs.
Changes:
- Add null checks for
brokerData/brokerData.getBrokerAddrs()while collecting current broker master addresses. - Skip null master addresses when building the existing broker address set.
- Add a regression test covering a malformed current broker row with null broker addresses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| proxy/src/main/java/org/apache/rocketmq/proxy/service/admin/DefaultAdminService.java | Skips malformed current broker entries when collecting existing broker addresses to avoid NPE. |
| proxy/src/test/java/org/apache/rocketmq/proxy/service/admin/DefaultAdminServiceTest.java | Adds regression coverage ensuring topic creation proceeds even with malformed current broker data. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assertEquals("127.0.0.1:10911", addrArgumentCaptor.getValue()); | ||
| assertEquals("createTopic", topicConfigArgumentCaptor.getValue().getTopicName()); | ||
| } |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #10773 +/- ##
=============================================
+ Coverage 48.24% 48.26% +0.02%
- Complexity 13496 13502 +6
=============================================
Files 1380 1380
Lines 101104 101108 +4
Branches 13107 13109 +2
=============================================
+ Hits 48773 48800 +27
+ Misses 46350 46325 -25
- Partials 5981 5983 +2 ☔ 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/empty guards in DefaultProducerAssignor.assign() for brokerData and brokerData.getBrokerAddrs() before accessing the master address, preventing NullPointerException when broker metadata is missing or incomplete.
Findings
- [Info] The fix correctly handles three failure modes: null
brokerData, nullbrokerAddrsmap, and null master address. Each is skipped without throwing. - [Info] Test coverage is thorough —
testAssignWithMalformedBrokerDataverifies the FORBIDDEN result when broker data is null, andtestAssignWithNullMasterAddressverifies handling of missing master address.
Suggestions
- None. Clean defensive fix with proper test coverage.
LGTM.
Automated review by github-manager-bot
What changed
This PR makes
DefaultAdminService#createTopicOnBrokerskip malformed current broker rows while collecting existing broker addresses.The sample broker loop already handled null broker address maps, but the current broker loop dereferenced
brokerData.getBrokerAddrs()directly.Why
A malformed current route row should not prevent Proxy admin topic creation from proceeding on valid sample brokers.
Fixes #10772.
Verification
mvn -pl proxy -Dtest=DefaultAdminServiceTest testResult: BUILD SUCCESS.
DefaultAdminServiceTestran 2 tests with 0 failures/errors/skips. Checkstyle and SpotBugs also passed in the Maven run.