You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "daguimu (via GitHub)" <gi...@apache.org> on 2026/03/26 15:48:23 UTC
[PR] [ISSUE #10216] Fix potential NPE in EscapeBridge when topicPublishInfo is null [rocketmq]
daguimu opened a new pull request, #10217:
URL: https://github.com/apache/rocketmq/pull/10217
## 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
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org