Skip to content

Commit 54afc3b

Browse files
authored
Fix Session reconnection increase connection number (#15677)
* Fix Session reconnection increase connection number * Fix Session reconnection increase connection number * Optimize the implement
1 parent 5c7cb1e commit 54afc3b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

iotdb-client/session/src/main/java/org/apache/iotdb/session/SessionConnection.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,18 @@ private boolean reconnect() {
10531053
if (session.endPointToSessionConnection == null) {
10541054
session.endPointToSessionConnection = new ConcurrentHashMap<>();
10551055
}
1056-
session.endPointToSessionConnection.put(session.defaultEndPoint, this);
1056+
session.endPointToSessionConnection.compute(
1057+
session.defaultEndPoint,
1058+
(k, v) -> {
1059+
if (v != null && v.transport != null && v.transport.isOpen()) {
1060+
try {
1061+
v.close();
1062+
} catch (IoTDBConnectionException e) {
1063+
logger.warn("close connection failed, {}", e.getMessage());
1064+
}
1065+
}
1066+
return this;
1067+
});
10571068
break;
10581069
}
10591070
}

0 commit comments

Comments
 (0)