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

earthchen pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new 2cf54f7947 Close the connection but not the client (#13600)
2cf54f7947 is described below

commit 2cf54f7947596abbf92f907853a2df7cbfc8b7fb
Author: icodening <[email protected]>
AuthorDate: Fri Jan 19 18:19:57 2024 +0800

    Close the connection but not the client (#13600)
    
    * Close the connection but not the client
    
    * Close the connection but not the client
---
 .../dubbo/remoting/transport/netty4/NettyConnectionClient.java     | 7 +++----
 .../org/apache/dubbo/rpc/protocol/tri/TriplePingPongHandler.java   | 4 +++-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConnectionClient.java
 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConnectionClient.java
index 3e2fd50657..6f3171363c 100644
--- 
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConnectionClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConnectionClient.java
@@ -131,7 +131,8 @@ public class NettyConnectionClient extends 
AbstractConnectionClient {
 
                 NettyConfigOperator operator = new 
NettyConfigOperator(nettyChannel, getChannelHandler());
                 protocol.configClientPipeline(getUrl(), operator, 
nettySslContextOperator);
-                ch.closeFuture().addListener(channelFuture -> doClose());
+                // set null but do not close this client, it will be reconnect 
in the future
+                ch.closeFuture().addListener(channelFuture -> 
channel.set(null));
                 // TODO support Socks5
             }
         });
@@ -150,9 +151,7 @@ public class NettyConnectionClient extends 
AbstractConnectionClient {
                 current.close();
             }
             this.channel.set(null);
-            if (!closePromise.isDone()) {
-                closePromise.setSuccess(null);
-            }
+            closePromise.setSuccess(null);
         }
     }
 
diff --git 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriplePingPongHandler.java
 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriplePingPongHandler.java
index b2134f330f..c767ee92ef 100644
--- 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriplePingPongHandler.java
+++ 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TriplePingPongHandler.java
@@ -70,7 +70,9 @@ public class TriplePingPongHandler extends 
ChannelDuplexHandler {
 
         @Override
         public void run() {
-            ctx.close();
+            if (ctx.channel().isActive()) {
+                ctx.close();
+            }
         }
     }
 }

Reply via email to