SteveYurongSu commented on code in PR #14929:
URL: https://github.com/apache/iotdb/pull/14929#discussion_r1968837224
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/connector/client/IoTDBDataNodeAsyncClientManager.java:
##########
@@ -287,6 +288,10 @@ public void onError(final Exception e) {
if (exception.get() != null) {
throw new PipeConnectionException("Failed to handshake.",
exception.get());
}
+ } catch (TException e) {
+ client.resetMethodStateIfStopped();
+ throw new PipeConnectionException(
+ "Handshake failed because the ClientManager has been closed.", e);
Review Comment:
rethrow instead of throwing new exception?
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/client/async/AsyncPipeDataTransferServiceClient.java:
##########
@@ -157,6 +157,19 @@ public void markHandshakeFinished() {
LOGGER.info("Handshake finished for client {}", this);
}
+ // To ensure that the socket will be closed eventually, we need to manually
close the socket here,
+ // because the Client object may have thrown an exception before entering
the asynchronous thread,
+ // and the returnSelf method may not be called, resulting in resource
leakage.
+ public void resetMethodStateIfStopped() {
+ if (!___manager.isRunning()) {
+ if (___transport != null && ___transport.isOpen()) {
+ ___transport.close();
+ }
+
+ ___currentMethod = null;
Review Comment:
Add some logs here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]