Senrian opened a new pull request, #10232:
URL: https://github.com/apache/rocketmq/pull/10232
## 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()`:
```java
final TopicPublishInfo topicPublishInfo =
this.brokerController.getTopicRouteInfoManager().tryToFindTopicPublishInfo(messageExt.getTopic());
final MessageQueue mqSelected = topicPublishInfo.selectOneMessageQueue(); //
NPE if null
```
### Location 2 - `asyncRemotePutMessageToSpecificQueue()`:
```java
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()`:
```java
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.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]