Skip to content

Commit

Permalink
解决sslSock对象资源未释放的问题
Browse files Browse the repository at this point in the history
增加对sslSock变量的释放操作,防止资源未释放导致内存溢出
  • Loading branch information
zwc401 authored Aug 3, 2023
1 parent db40a5c commit d48d312
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ private static String send4LetterWord(
sslSock.connect(hostaddress, timeout);
sslSock.startHandshake();
socket = sslSock;
if (sslSock != null) {
try {
sslSock.close();
} catch (IOException e) {
LOGGER.error(
"method=send4LetterWord||host={}||port={}||cmd={}||secure={}||timeout={}||errMsg=exception!",
host, port, cmd, secure, timeout, e
);
}
}
}
} else {
socket = new Socket();
Expand Down

0 comments on commit d48d312

Please sign in to comment.