yyqdbngt opened a new pull request, #10744:
URL: https://github.com/apache/rocketmq/pull/10744

   ### Motivation
   
   `TopicRouteWrapper.getMasterAddr` and `getMasterAddrPrefer` called 
`brokerNameRouteData.get(brokerName).getBrokerAddrs()` without a null check. 
When `brokerName` is not present in the current route snapshot (e.g. during 
broker failover, or a stale `MessageQueue` referencing a broker no longer in 
the route), `get(brokerName)` returns `null` and the chained `getBrokerAddrs()` 
throws `NullPointerException`.
   
   This contradicts the contract the callers rely on. In 
`MessageQueueSelector.buildRead`/`buildWrite` and `ClusterTopicRouteService`, 
every call site checks the return value for `null` and skips the broker:
   
   ```java
   String brokerAddr = topicRoute.getMasterAddr(qd.getBrokerName());
   if (brokerAddr == null) {
       continue;
   }
   ```
   
   So these methods are *supposed* to return `null` for a missing broker, but 
instead they throw. The fix guards the lookup and returns `null`, making the 
existing caller handling work as intended.
   
   ### Verification
   
   `mvn -pl proxy -am compile` passes on the build server.
   
   ### Diff
   
   1 file changed, +10 / -2.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to