-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Before Creating the Bug Report
-
I found a bug, not just asking a question, which should be created in GitHub Discussions.
-
I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.
-
I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.
Runtime platform environment
All platforms
RocketMQ version
develop branch (latest)
JDK Version
JDK 8+
Describe the Bug
In EscapeBridge.java, the methods asyncPutMessage() and asyncRemotePutMessageToSpecificQueue() call tryToFindTopicPublishInfo() but do not check for a null return value before dereferencing the result.
Location 1 - asyncPutMessage() (line ~187-190):
final TopicPublishInfo topicPublishInfo = this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
final String producerGroup = getProducerGroup(messageExt);
final MessageQueue mqSelected = topicPublishInfo.selectOneMessageQueue(); // NPE if topicPublishInfo is nullLocation 2 - asyncRemotePutMessageToSpecificQueue() (line ~252-253):
final TopicPublishInfo topicPublishInfo = this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
List<MessageQueue> mqs = topicPublishInfo.getMessageQueueList(); // NPE if topicPublishInfo is nullIn contrast, the putMessageToRemoteBroker() method in the same class (line ~126-131) properly handles this:
if (null == topicPublishInfo || !topicPublishInfo.ok()) {
LOG.warn("putMessageToRemoteBroker: no route info ...");
return null;
}Steps to Reproduce
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), tryToFindTopicPublishInfo() returns null, leading to NPE.
What Did You Expect to See?
The methods should check for null topicPublishInfo and return an appropriate error result, consistent with putMessageToRemoteBroker().
What Did You See Instead?
NullPointerException when topicPublishInfo is null.
Additional Context
The fix should add null/validity checks for topicPublishInfo consistent with the existing pattern in putMessageToRemoteBroker().