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

jackietien pushed a commit to branch ty/nodesupplierbug
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 62e4d1534c4e20d144db39bc6e0114e5c68dcf97
Author: JackieTien97 <[email protected]>
AuthorDate: Fri Mar 15 10:53:50 2024 +0800

    Fix Concurrent bug between NodeSupplier.close() and its run()
---
 .../src/main/java/org/apache/iotdb/session/NodesSupplier.java      | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java
 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java
index ccb83b9a12d..8f0244bbcab 100644
--- 
a/iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java
+++ 
b/iotdb-client/session/src/main/java/org/apache/iotdb/session/NodesSupplier.java
@@ -170,8 +170,11 @@ public class NodesSupplier implements INodeSupplier, 
Runnable {
       }
     }
 
-    if (client != null && !updateDataNodeList()) {
-      destroyCurrentClient();
+    // make sure the following code block can run thread-safely with close() 
method.
+    synchronized (this) {
+      if (client != null && !updateDataNodeList()) {
+        destroyCurrentClient();
+      }
     }
   }
 

Reply via email to