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

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


The following commit(s) were added to refs/heads/master by this push:
     new a3c451e6be7 Pipe: Fixed the OPC UA bug that drop pipe may not erase 
the client (#17510)
a3c451e6be7 is described below

commit a3c451e6be724bb7f2a199bb5ba77b85cc4a0a6b
Author: Caideyipi <[email protected]>
AuthorDate: Mon Apr 20 14:10:35 2026 +0800

    Pipe: Fixed the OPC UA bug that drop pipe may not erase the client (#17510)
---
 .../db/pipe/sink/protocol/opcua/OpcUaSink.java     | 56 ++++++++++------------
 1 file changed, 26 insertions(+), 30 deletions(-)

diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaSink.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaSink.java
index 554ac3b0df4..532ebf60159 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaSink.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/opcua/OpcUaSink.java
@@ -550,42 +550,38 @@ public class OpcUaSink implements PipeConnector {
 
   @Override
   public void close() throws Exception {
-    if (serverKey == null) {
-      return;
-    }
-
-    synchronized (SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP) {
-      final Pair<AtomicInteger, OpcUaNameSpace> pair =
-          SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP.get(serverKey);
-      if (pair == null) {
-        return;
-      }
+    if (serverKey != null) {
+      synchronized (SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP) {
+        final Pair<AtomicInteger, OpcUaNameSpace> pair =
+            SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP.get(serverKey);
+        if (pair == null) {
+          return;
+        }
 
-      if (pair.getLeft().decrementAndGet() <= 0) {
-        try {
-          pair.getRight().shutdown();
-        } finally {
-          SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP.remove(serverKey);
+        if (pair.getLeft().decrementAndGet() <= 0) {
+          try {
+            pair.getRight().shutdown();
+          } finally {
+            SERVER_KEY_TO_REFERENCE_COUNT_AND_NAME_SPACE_MAP.remove(serverKey);
+          }
         }
       }
     }
 
-    if (nodeUrl == null) {
-      return;
-    }
-
-    synchronized (CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP) {
-      final Pair<AtomicInteger, IoTDBOpcUaClient> pair =
-          CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP.get(nodeUrl);
-      if (pair == null) {
-        return;
-      }
+    if (nodeUrl != null) {
+      synchronized (CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP) {
+        final Pair<AtomicInteger, IoTDBOpcUaClient> pair =
+            CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP.get(nodeUrl);
+        if (pair == null) {
+          return;
+        }
 
-      if (pair.getLeft().decrementAndGet() <= 0) {
-        try {
-          pair.getRight().disconnect();
-        } finally {
-          CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP.remove(nodeUrl);
+        if (pair.getLeft().decrementAndGet() <= 0) {
+          try {
+            pair.getRight().disconnect();
+          } finally {
+            CLIENT_KEY_TO_REFERENCE_COUNT_AND_CLIENT_MAP.remove(nodeUrl);
+          }
         }
       }
     }

Reply via email to