You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/09/23 09:15:24 UTC

[rocketmq] branch develop updated: [ISSUE #5151]Reduce redundant for loops (#5154)

This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 590a680c3 [ISSUE #5151]Reduce redundant for loops (#5154)
590a680c3 is described below

commit 590a680c38f6aaf8f01581503a6338f08256914e
Author: RapperCL <44...@users.noreply.github.com>
AuthorDate: Fri Sep 23 17:15:17 2022 +0800

    [ISSUE #5151]Reduce redundant for loops (#5154)
    
    * [ISSUE #5151]Reduce redundant for loops
    
    * [ISSUE #5151] code re-format
    
    Co-authored-by: chenyong <ch...@highlight.mobi>
---
 .../client/impl/consumer/RebalanceImpl.java         | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
index ef763bc99..3b7281606 100644
--- a/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
+++ b/client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalanceImpl.java
@@ -208,21 +208,16 @@ public abstract class RebalanceImpl {
                     Set<MessageQueue> lockOKMQSet =
                         this.mQClientFactory.getMQClientAPIImpl().lockBatchMQ(findBrokerResult.getBrokerAddr(), requestBody, 1000);
 
-                    for (MessageQueue mq : lockOKMQSet) {
+                    for (MessageQueue mq : mqs) {
                         ProcessQueue processQueue = this.processQueueTable.get(mq);
                         if (processQueue != null) {
-                            if (!processQueue.isLocked()) {
-                                log.info("the message queue locked OK, Group: {} {}", this.consumerGroup, mq);
-                            }
-
-                            processQueue.setLocked(true);
-                            processQueue.setLastLockTimestamp(System.currentTimeMillis());
-                        }
-                    }
-                    for (MessageQueue mq : mqs) {
-                        if (!lockOKMQSet.contains(mq)) {
-                            ProcessQueue processQueue = this.processQueueTable.get(mq);
-                            if (processQueue != null) {
+                            if (lockOKMQSet.contains(mq)) {
+                                if (!processQueue.isLocked()) {
+                                    log.info("the message queue locked OK, Group: {} {}", this.consumerGroup, mq);
+                                }
+                                processQueue.setLocked(true);
+                                processQueue.setLastLockTimestamp(System.currentTimeMillis());
+                            } else {
                                 processQueue.setLocked(false);
                                 log.warn("the message queue locked Failed, Group: {} {}", this.consumerGroup, mq);
                             }