This is an automated email from the ASF dual-hosted git repository.
jt2594838 pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new c1556669dc3 Pipe: Fixed the OPC UA bug that drop pipe may not erase
the client (#17510) (#17522)
c1556669dc3 is described below
commit c1556669dc35089945ec320e5669a419aad08db7
Author: Caideyipi <[email protected]>
AuthorDate: Tue Apr 21 11:02:23 2026 +0800
Pipe: Fixed the OPC UA bug that drop pipe may not erase the client (#17510)
(#17522)
---
.../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 e1985061224..03a8e6fba83 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
@@ -518,42 +518,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);
+ }
}
}
}