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

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


The following commit(s) were added to refs/heads/master by this push:
     new ebe225a  [2.7] Fix issue where dead connections would not be 
reconnected. (#9327)
ebe225a is described below

commit ebe225a32dcf04f1769a5b41f56aaa06bbce3570
Author: stone 98 <[email protected]>
AuthorDate: Sun Nov 28 23:19:24 2021 +0800

    [2.7] Fix issue where dead connections would not be reconnected. (#9327)
---
 .../dubbo/remoting/transport/AbstractClient.java   | 28 ++++++++++------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git 
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java
 
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java
index f263fd0..89aa130 100644
--- 
a/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java
+++ 
b/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/AbstractClient.java
@@ -199,14 +199,14 @@ public abstract class AbstractClient extends 
AbstractEndpoint implements Client
 
             if (!isConnected()) {
                 throw new RemotingException(this, "Failed connect to server " 
+ getRemoteAddress() + " from " + getClass().getSimpleName() + " "
-                                + NetUtils.getLocalHost() + " using dubbo 
version " + Version.getVersion()
-                                + ", cause: Connect wait timeout: " + 
getConnectTimeout() + "ms.");
+                        + NetUtils.getLocalHost() + " using dubbo version " + 
Version.getVersion()
+                        + ", cause: Connect wait timeout: " + 
getConnectTimeout() + "ms.");
 
             } else {
                 if (logger.isInfoEnabled()) {
                     logger.info("Successed connect to server " + 
getRemoteAddress() + " from " + getClass().getSimpleName() + " "
-                                    + NetUtils.getLocalHost() + " using dubbo 
version " + Version.getVersion()
-                                    + ", channel is " + this.getChannel());
+                            + NetUtils.getLocalHost() + " using dubbo version 
" + Version.getVersion()
+                            + ", channel is " + this.getChannel());
                 }
             }
 
@@ -215,8 +215,8 @@ public abstract class AbstractClient extends 
AbstractEndpoint implements Client
 
         } catch (Throwable e) {
             throw new RemotingException(this, "Failed connect to server " + 
getRemoteAddress() + " from " + getClass().getSimpleName() + " "
-                            + NetUtils.getLocalHost() + " using dubbo version 
" + Version.getVersion()
-                            + ", cause: " + e.getMessage(), e);
+                    + NetUtils.getLocalHost() + " using dubbo version " + 
Version.getVersion()
+                    + ", cause: " + e.getMessage(), e);
 
         } finally {
             connectLock.unlock();
@@ -246,16 +246,12 @@ public abstract class AbstractClient extends 
AbstractEndpoint implements Client
 
     @Override
     public void reconnect() throws RemotingException {
-        if (!isConnected()) {
-            connectLock.lock();
-            try {
-                if (!isConnected()) {
-                    disconnect();
-                    connect();
-                }
-            } finally {
-                connectLock.unlock();
-            }
+        connectLock.lock();
+        try {
+            disconnect();
+            connect();
+        } finally {
+            connectLock.unlock();
         }
     }
 

Reply via email to