Skip to content

[Bug] Fix potential NPE in EscapeBridge when topicPublishInfo is null#10232

Open
Senrian wants to merge 1 commit intoapache:developfrom
Senrian:fix-npe-escape-bridge
Open

[Bug] Fix potential NPE in EscapeBridge when topicPublishInfo is null#10232
Senrian wants to merge 1 commit intoapache:developfrom
Senrian:fix-npe-escape-bridge

Conversation

@Senrian
Copy link
Copy Markdown

@Senrian Senrian commented Mar 30, 2026

Bug Description

In EscapeBridge.java, the methods asyncPutMessage() and asyncRemotePutMessageToSpecificQueue() call tryToFindTopicPublishInfo() but do not check for a null return value before dereferencing.

Issue: #10216

Location 1 - asyncPutMessage():

final TopicPublishInfo topicPublishInfo = this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
final MessageQueue mqSelected = topicPublishInfo.selectOneMessageQueue(); // NPE if null

Location 2 - asyncRemotePutMessageToSpecificQueue():

final TopicPublishInfo topicPublishInfo = this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
List<MessageQueue> mqs = topicPublishInfo.getMessageQueueList(); // NPE if null

Fix

Add null checks consistent with the existing pattern in putMessageToRemoteBroker():

if (null == topicPublishInfo || !topicPublishInfo.ok()) {
    LOG.warn("asyncPutMessage: no route info of topic {}...", ...);
    return CompletableFuture.completedFuture(new PutMessageResult(PutMessageStatus.PUT_TO_REMOTE_BROKER_FAIL, null, true));
}

This prevents NPE when a slave broker acting as master attempts to escape a message for a topic whose route information is not yet available.

Issue: apache#10216

Add null checks for topicPublishInfo in asyncPutMessage() and
asyncRemotePutMessageToSpecificQueue() methods, consistent with
the existing pattern in putMessageToRemoteBroker().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant