This is an automated email from the ASF dual-hosted git repository.
jiangtian 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 54afc3b67c4 Fix Session reconnection increase connection number
(#15677)
54afc3b67c4 is described below
commit 54afc3b67c4ed9c1d1d5247c8cd6593ac1844115
Author: Haonan <[email protected]>
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 4d4fdc28041..cfef7bfb6f7 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
@@ -1053,7 +1053,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;
}
}