Skip to content

[ISSUE #10216] Fix potential NPE in EscapeBridge when topicPublishInfo is null#10217

Open
daguimu wants to merge 1 commit intoapache:developfrom
daguimu:fix/escapebridge-npe-10216
Open

[ISSUE #10216] Fix potential NPE in EscapeBridge when topicPublishInfo is null#10217
daguimu wants to merge 1 commit intoapache:developfrom
daguimu:fix/escapebridge-npe-10216

Conversation

@daguimu
Copy link
Copy Markdown

@daguimu daguimu commented Mar 26, 2026

Problem

EscapeBridge.asyncPutMessage() and asyncRemotePutMessageToSpecificQueue() dereference the return value of tryToFindTopicPublishInfo() without null checks, causing NullPointerException when topic route information is unavailable.

Root Cause

tryToFindTopicPublishInfo() can return null when the topic route is not yet available (e.g., during broker startup or after nameserver disconnection). The putMessageToRemoteBroker() method in the same class already handles this correctly with a null/validity check, but asyncPutMessage() and asyncRemotePutMessageToSpecificQueue() were missing this guard.

Fix

  • asyncPutMessage(): Add null == topicPublishInfo || !topicPublishInfo.ok() check before calling selectOneMessageQueue(), returning PUT_TO_REMOTE_BROKER_FAIL with a warning log, consistent with putMessageToRemoteBroker().
  • asyncRemotePutMessageToSpecificQueue(): Add the same null/validity check before calling getMessageQueueList().

Tests Added

Change Point Test
Null check in asyncPutMessage() testAsyncPutMessageWhenTopicPublishInfoIsNull() — verifies PUT_TO_REMOTE_BROKER_FAIL when info is null
Validity check in asyncPutMessage() testAsyncPutMessageWhenTopicPublishInfoNotOk() — verifies same result when info has no queues
Null check in asyncRemotePutMessageToSpecificQueue() testAsyncRemotePutMessageToSpecificQueueWhenTopicPublishInfoIsNull() — verifies safe handling
Validity check in asyncRemotePutMessageToSpecificQueue() testAsyncRemotePutMessageToSpecificQueueWhenTopicPublishInfoNotOk() — verifies same result

Impact

Only affects the escape bridge failover path when slave acts as master. Normal message put operations are unaffected. The fix makes error handling consistent across all methods in EscapeBridge.

Fixes #10216

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.

[Bug] Potential NPE in EscapeBridge when topicPublishInfo is null

1 participant