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

lizhimin 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 e8d1472fb7 [ISSUE #8712] Set namesrvAddrChoosed to null if choosed 
addr is not exist (#8713)
e8d1472fb7 is described below

commit e8d1472fb7a592ee605a7e7a12faef82e8c672fa
Author: qianye <37405937+qianye1...@users.noreply.github.com>
AuthorDate: Mon Sep 23 12:28:42 2024 +0800

    [ISSUE #8712] Set namesrvAddrChoosed to null if choosed addr is not exist 
(#8713)
---
 .../org/apache/rocketmq/remoting/netty/NettyRemotingClient.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
 
b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
index ef9762ddc6..ae82b09eda 100644
--- 
a/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
+++ 
b/remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingClient.java
@@ -520,10 +520,11 @@ public class NettyRemotingClient extends 
NettyRemotingAbstract implements Remoti
                 this.namesrvAddrList.set(addrs);
 
                 // should close the channel if choosed addr is not exist.
-                if (this.namesrvAddrChoosed.get() != null && 
!addrs.contains(this.namesrvAddrChoosed.get())) {
-                    String namesrvAddr = this.namesrvAddrChoosed.get();
+                String chosenNameServerAddr = this.namesrvAddrChoosed.get();
+                if (chosenNameServerAddr != null && 
!addrs.contains(chosenNameServerAddr)) {
+                    namesrvAddrChoosed.compareAndSet(chosenNameServerAddr, 
null);
                     for (String addr : this.channelTables.keySet()) {
-                        if (addr.contains(namesrvAddr)) {
+                        if (addr.contains(chosenNameServerAddr)) {
                             ChannelWrapper channelWrapper = 
this.channelTables.get(addr);
                             if (channelWrapper != null) {
                                 channelWrapper.close();

Reply via email to