This is an automated email from the ASF dual-hosted git repository.

ShannonDing pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new da58317516 [ISSUE #10216] Fix potential NPE in EscapeBridge when 
topicPublishInfo is null (#10507)
da58317516 is described below

commit da58317516cfbb034358ef981396576a0719cf6b
Author: SGloria <[email protected]>
AuthorDate: Mon Jun 15 13:40:42 2026 +0800

    [ISSUE #10216] Fix potential NPE in EscapeBridge when topicPublishInfo is 
null (#10507)
    
    In asyncPutMessage() and asyncRemotePutMessageToSpecificQueue(), the
    return value of tryToFindTopicPublishInfo() is dereferenced without a
    null check, causing NullPointerException when topic route information
    is unavailable (e.g., during startup or after nameserver disconnection).
    
    This commit adds null/validity checks consistent with the existing
    pattern in putMessageToRemoteBroker(), returning PUT_TO_REMOTE_BROKER_FAIL
    with a warning log instead of crashing with NPE.
    
    Co-authored-by: fire <[email protected]>
    Co-authored-by: Cursor <[email protected]>
---
 .../java/org/apache/rocketmq/broker/failover/EscapeBridge.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git 
a/broker/src/main/java/org/apache/rocketmq/broker/failover/EscapeBridge.java 
b/broker/src/main/java/org/apache/rocketmq/broker/failover/EscapeBridge.java
index dd37f42b2c..84dcccaf75 100644
--- a/broker/src/main/java/org/apache/rocketmq/broker/failover/EscapeBridge.java
+++ b/broker/src/main/java/org/apache/rocketmq/broker/failover/EscapeBridge.java
@@ -185,6 +185,11 @@ public class EscapeBridge {
                 messageExt.setWaitStoreMsgOK(false);
 
                 final TopicPublishInfo topicPublishInfo = 
this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
+                if (null == topicPublishInfo || !topicPublishInfo.ok()) {
+                    LOG.warn("asyncPutMessage: no route info of topic {} when 
escaping message, msgId={}",
+                        messageExt.getTopic(), messageExt.getMsgId());
+                    return CompletableFuture.completedFuture(new 
PutMessageResult(PutMessageStatus.PUT_TO_REMOTE_BROKER_FAIL, null, true));
+                }
                 final String producerGroup = getProducerGroup(messageExt);
 
                 final MessageQueue mqSelected = 
topicPublishInfo.selectOneMessageQueue();
@@ -250,6 +255,11 @@ public class EscapeBridge {
                 messageExt.setWaitStoreMsgOK(false);
 
                 final TopicPublishInfo topicPublishInfo = 
this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
+                if (null == topicPublishInfo || !topicPublishInfo.ok()) {
+                    LOG.warn("asyncRemotePutMessageToSpecificQueue: no route 
info of topic {} when escaping message, msgId={}",
+                        messageExt.getTopic(), messageExt.getMsgId());
+                    return CompletableFuture.completedFuture(new 
PutMessageResult(PutMessageStatus.PUT_TO_REMOTE_BROKER_FAIL, null, true));
+                }
                 List<MessageQueue> mqs = 
topicPublishInfo.getMessageQueueList();
 
                 if (null == mqs || mqs.isEmpty()) {

Reply via email to