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

   ## Summary
   
   Fix NullPointerException in `EscapeBridge` when 
`tryToFindTopicPublishInfo()` returns null.
   
   ## Motivation
   
   In `EscapeBridge.java`, two methods dereference the result of 
`tryToFindTopicPublishInfo()` without null checks:
   
   1. `asyncPutMessage()` — calls `topicPublishInfo.selectOneMessageQueue()` 
directly
   2. `asyncRemotePutMessageToSpecificQueue()` — calls 
`topicPublishInfo.getMessageQueueList()` directly
   
   When a slave broker acting as master attempts to escape a message for a 
topic whose route information is not yet available (e.g., during startup or 
after a nameserver disconnection), this causes NPE.
   
   In contrast, `putMessageToRemoteBroker()` in the same class already handles 
this correctly:
   ```java
   if (null == topicPublishInfo || !topicPublishInfo.ok()) {
       LOG.warn("putMessageToRemoteBroker: no route info ...");
       return null;
   }
   ```
   
   ## Changes
   
   - Added null/validity checks (`null == topicPublishInfo || 
!topicPublishInfo.ok()`) in both methods
   - Return `PutMessageStatus.PUT_TO_REMOTE_BROKER_FAIL` with a warning log, 
consistent with the existing pattern
   - No behavioral change when `topicPublishInfo` is valid
   
   ## Test Plan
   
   - [x] Code compiles without errors (`mvn compile -pl broker -am`)
   - [x] Fix follows the exact same pattern as `putMessageToRemoteBroker()` in 
the same file
   - [x] No new dependencies or API changes introduced
   
   Fixes #10216
   
   Made with [Cursor](https://cursor.com)


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