zjncs opened a new pull request, #11115:
URL: https://github.com/apache/rocketmq/pull/11115

   ## Motivation
   
   `MQClientInstance.topicRouteData2TopicPublishInfo` parses the order-topic 
route config with no guard:
   
   ```java
   String[] item = broker.split(":");
   int nums = Integer.parseInt(item[1]);
   ```
   
   `orderTopicConf` is a manually configured string stored on the nameserver 
(e.g. `broker-a:8;broker-b:4`). A single mistyped segment — missing the 
`brokerName:queueNum` shape, or a non-numeric count — makes the method throw a 
raw `ArrayIndexOutOfBoundsException`/`NumberFormatException`.
   
   The method is called from `updateTopicRouteInfoFromNameServer`, whose catch 
clauses only cover `MQClientException`/`RemotingException`, so the runtime 
exception escapes through the whole route refresh: the topic never gets publish 
info, every producer on the client keeps failing queue selection for that 
topic, and the only trace is an unrelated-looking stack trace. 
`fetchPublishMessageQueues` degrades to a misleading "Can not find Message 
Queue" as well.
   
   ## Modification
   
   Parse each segment defensively: a segment that does not match the 
`brokerName:queueNum` shape or whose count is not numeric is skipped with a 
warn log, so only its own queues are dropped and the remaining valid brokers 
stay routable. Well-formed configurations are unaffected.
   
   ## Test Evidence
   
   **Fail-before** (unpatched code, new test 
`MQClientInstanceTest#testTopicRouteData2TopicPublishInfoWithMalformedOrderTopicConf`
 with conf `127.0.0.1:2;malformed;broker-b:notANumber;127.0.0.2:1`):
   
   ```
   docker exec rmq-build mvn -q -pl client test 
-Dtest='MQClientInstanceTest#testTopicRouteData2TopicPublishInfoWithMalformedOrderTopicConf'
 -Dsurefire.failIfNoSpecifiedTests=true
   Tests run: 1, Errors: 1 ... java.lang.ArrayIndexOutOfBoundsException: Index 
1 out of bounds for length 1
   ```
   
   **Pass-after** (full class with the fix — malformed segments skipped, the 3 
queues of the two valid brokers still produced):
   
   ```
   docker exec rmq-build mvn -q -pl client test -Dtest='MQClientInstanceTest' 
-Dsurefire.failIfNoSpecifiedTests=true
   Tests run: 30, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   No associated issue (self-discovered during a client-module self-audit).


-- 
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]

Reply via email to