This is an automated email from the ASF dual-hosted git repository.
Caideyipi pushed a commit to branch drop-erase
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/drop-erase by this push:
new 728ec1632d7 Pipe: Fixed the OPC UA bug that drop pipe may not erase
the client (#17510)
728ec1632d7 is described below
commit 728ec1632d7d05cb6224a606a97fb30277f0edf5
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 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);
+ }
}
}
}