You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2021/11/01 13:46:40 UTC

[activemq-artemis] branch main updated: ARTEMIS-3547 remove first field to improve code

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

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 89253b8  ARTEMIS-3547 remove first field to improve code
     new e37f2ac  This closes #3831
89253b8 is described below

commit 89253b8513d597af04c631ce0b32882113e5d84b
Author: domson-tech <85...@users.noreply.github.com>
AuthorDate: Mon Nov 1 20:53:15 2021 +0800

    ARTEMIS-3547 remove first field to improve code
    
    first field is not necessary here, only pos field can work.
    So remove first here.
---
 .../loadbalance/RoundRobinConnectionLoadBalancingPolicy.java       | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java
index 388cf34..60ad022 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/loadbalance/RoundRobinConnectionLoadBalancingPolicy.java
@@ -31,17 +31,14 @@ public final class RoundRobinConnectionLoadBalancingPolicy implements Connection
 
    private static final long serialVersionUID = 7511196010141439559L;
 
-   private boolean first = true;
-
-   private int pos;
+   private int pos = -1;
 
    @Override
    public int select(final int max) {
-      if (first) {
+      if (pos == -1) {
          // We start on a random one
          pos = RandomUtil.randomInterval(0, max);
 
-         first = false;
       } else {
          pos++;