Skip to content

[Bug] Return null when broker address table is unavailable - #11031

Open
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/broker-data-empty-addresses
Open

[Bug] Return null when broker address table is unavailable#11031
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/broker-data-empty-addresses

Conversation

@zjncs

@zjncs zjncs commented Sep 5, 2026

Copy link
Copy Markdown

Fixes #10873

BrokerData.selectBrokerAddr now returns null when brokerAddrs is null or empty, instead of throwing NullPointerException or IllegalArgumentException from Random.nextInt(0). Master preference and random slave fallback remain unchanged.

Added regression coverage for both null and empty tables.

Verification: git diff --check passed; Maven unavailable locally, CI should run BrokerDataTest/remoting checks. AI-assisted contribution.

Signed-off-by: zjncs <18910855655@163.com>
@zjncs
zjncs marked this pull request as ready for review September 5, 2026 09:29
Copilot AI lite review requested due to automatic review settings September 5, 2026 09:29

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Summary

Good defensive fix — adds null/empty check to selectBrokerAddr() to prevent NPE when broker address table is unavailable. Returns null gracefully instead of throwing.

The test validates both null and empty map cases.

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] BrokerData.selectBrokerAddr crashes for an empty address table

3 participants