You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2025/11/26 02:05:19 UTC
(iotdb) 01/02: Fix Session reconnection increase connection number (#15677)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch cp_fix_connection_leak
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 72283e6854927159649081986e22e3be1a4bedae
Author: Haonan <hh...@outlook.com>
AuthorDate: Tue Jun 10 10:22:04 2025 +0800
Fix Session reconnection increase connection number (#15677)
* Fix Session reconnection increase connection number
* Fix Session reconnection increase connection number
* Optimize the implement
---
.../java/org/apache/iotdb/session/SessionConnection.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
index bee82eb2f14..448f9af356f 100644
--- a/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
+++ b/iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java
@@ -956,7 +956,18 @@ public class SessionConnection {
if (session.endPointToSessionConnection == null) {
session.endPointToSessionConnection = new ConcurrentHashMap<>();
}
- session.endPointToSessionConnection.put(session.defaultEndPoint, this);
+ session.endPointToSessionConnection.compute(
+ session.defaultEndPoint,
+ (k, v) -> {
+ if (v != null && v.transport != null && v.transport.isOpen()) {
+ try {
+ v.close();
+ } catch (IoTDBConnectionException e) {
+ logger.warn("close connection failed, {}", e.getMessage());
+ }
+ }
+ return this;
+ });
break;
}
}