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

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


The following commit(s) were added to refs/heads/master by this push:
     new 12f6e4c72ff fix connectionPostProcessors clear when channel inactive 
(#18734) (#18750)
12f6e4c72ff is described below

commit 12f6e4c72ff58bd4b0389291e0058b00994f0b5f
Author: hao.chen <[email protected]>
AuthorDate: Fri Jul 1 10:32:45 2022 +0800

    fix connectionPostProcessors clear when channel inactive (#18734) (#18750)
    
    Co-authored-by: 陈浩 <[email protected]>
---
 .../jdbc/connection/JDBCBackendConnection.java     | 24 +++++++++++++---------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
index efa51065178..8c0c6d076cc 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
@@ -262,19 +262,23 @@ public final class JDBCBackendConnection implements 
BackendConnection<Void>, Exe
      */
     public Collection<SQLException> closeConnections(final boolean 
forceRollback) {
         Collection<SQLException> result = new LinkedList<>();
-        for (Connection each : cachedConnections.values()) {
-            try {
-                if (forceRollback && 
connectionSession.getTransactionStatus().isInTransaction()) {
-                    each.rollback();
+        synchronized (cachedConnections) {
+            for (Connection each : cachedConnections.values()) {
+                try {
+                    if (forceRollback && 
connectionSession.getTransactionStatus().isInTransaction()) {
+                        each.rollback();
+                    }
+                    resetConnection(each);
+                    each.close();
+                } catch (final SQLException ex) {
+                    result.add(ex);
                 }
-                resetConnection(each);
-                each.close();
-            } catch (final SQLException ex) {
-                result.add(ex);
             }
+            cachedConnections.clear();
+        }
+        if (!forceRollback) {
+            connectionPostProcessors.clear();
         }
-        cachedConnections.clear();
-        connectionPostProcessors.clear();
         return result;
     }
     

Reply via email to