mz0113 commented on code in PR #4179:
URL: https://github.com/apache/rocketmq/pull/4179#discussion_r949280234


##########
client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java:
##########
@@ -69,16 +69,17 @@ public MessageQueue selectOneMessageQueue(final 
TopicPublishInfo tpInfo, final S
                 }
 
                 final String notBestBroker = 
latencyFaultTolerance.pickOneAtLeast();
-                int writeQueueNums = tpInfo.getQueueIdByBroker(notBestBroker);
-                if (writeQueueNums > 0) {
-                    final MessageQueue mq = tpInfo.selectOneMessageQueue();
-                    if (notBestBroker != null) {
+                if (notBestBroker != null) {
+                    int writeQueueNums = 
tpInfo.getQueueIdByBroker(notBestBroker);
+                    if (writeQueueNums > 0) {
+                        MessageQueue mq = new MessageQueue();
+                        
mq.setTopic(tpInfo.getMessageQueueList().get(0).getTopic());

Review Comment:
   > Why use Topic0 directly here?
   
   回复错人了我晕,我说这么久还没合进去。这个是因为  tpInfo.getMessageQueueList() 
的queue全部都是同一个topic下的,所以你取这个list的哪一个元素都行,直接取0是因为代码在这个位置可以明确这个list至少有一个元素在里面,所以取0不会导致数组越界,写其他的值可能导致越界。



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