Skip to content

[ISSUE #10772] Skip malformed current broker data - #10773

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-admin-skip-malformed-current-broker
Open

[ISSUE #10772] Skip malformed current broker data#10773
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-admin-skip-malformed-current-broker

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What changed

This PR makes DefaultAdminService#createTopicOnBroker skip 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 test

Result: BUILD SUCCESS. DefaultAdminServiceTest ran 2 tests with 0 failures/errors/skips. Checkstyle and SpotBugs also passed in the Maven run.

Copilot AI review requested due to automatic review settings August 3, 2026 06:44

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

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.

Comment on lines +110 to +112
assertEquals("127.0.0.1:10911", addrArgumentCaptor.getValue());
assertEquals("createTopic", topicConfigArgumentCaptor.getValue().getTopicName());
}
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.26%. Comparing base (eddb235) to head (3b7bb22).

Files with missing lines Patch % Lines
...ketmq/proxy/service/admin/DefaultAdminService.java 20.00% 3 Missing and 1 partial ⚠️
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.
📢 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 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, null brokerAddrs map, and null master address. Each is skipped without throwing.
  • [Info] Test coverage is thorough — testAssignWithMalformedBrokerData verifies the FORBIDDEN result when broker data is null, and testAssignWithNullMasterAddress verifies handling of missing master address.

Suggestions

  • None. Clean defensive fix with proper test coverage.

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] Proxy DefaultAdminService can NPE on malformed current broker data

4 participants