[ISSUE #10873] Guard BrokerData.selectBrokerAddr against empty address table - #10920
[ISSUE #10873] Guard BrokerData.selectBrokerAddr against empty address table#10920btlqql wants to merge 1 commit into
Conversation
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
This PR adds a null/empty check for brokerAddrs in BrokerData.selectBrokerAddr() before accessing the map. This prevents potential NullPointerException or unexpected behavior when the address table is empty.
LGTM. Simple defensive fix.
Note: This PR also includes changes from #10914-#10919. See the series overlap comment on those PRs.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review Summary
This PR adds a null/empty guard in BrokerData.selectBrokerAddr to prevent NPE when the address table is empty.
Findings
- [Critical] BrokerData.java — Without this guard, calling
selectBrokerAddron a broker with no registered addresses would throw NPE or return incorrect results. - [Info] Returning
nullfor empty address tables is the correct defensive behavior, allowing callers to handle the missing broker gracefully.
Overall
Good defensive fix. Prevents NPE in routing logic when broker addresses are not yet available or have been removed.
Automated review by RockteMQ-AI
aac534b to
0753ba4
Compare
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Trivial change, looks good.
Automated review by github-manager-bot
What is the purpose of the change
Fix #10873.
BrokerData.selectBrokerAddr assumed brokerAddrs is non-null and non-empty. A default BrokerData instance threw NullPointerException, while an empty map reached Random.nextInt(0) and threw IllegalArgumentException.
Brief changelog
How was this patch verified
git diff --checkclean