Skip to content

GH-9694: Remove duplicate SocketChannel initialization #9696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* @author Artem Bilan
* @author Christian Tzolov
* @author Ngoc Nhan
* @author Jooyoung Pyoung
*
* @since 2.0
*
Expand Down Expand Up @@ -85,8 +86,9 @@ protected void checkActive() {

@Override
protected TcpConnectionSupport buildNewConnection() {
SocketChannel socketChannel = null;
try {
SocketChannel socketChannel = SocketChannel.open();
socketChannel = SocketChannel.open();
setSocketAttributes(socketChannel.socket());
connect(socketChannel);
TcpNioConnection connection =
Expand All @@ -113,6 +115,14 @@ protected TcpConnectionSupport buildNewConnection() {
return wrappedConnection;
}
catch (IOException e) {
try {
if (socketChannel != null) {
socketChannel.close();
}
}
catch (IOException e2) {
logger.error(e2, "Error closing socket channel");
}
throw new UncheckedIOException(e);
}
catch (InterruptedException e) {
Expand Down
Loading