-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
@anthologia Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@anthologia Thank you for signing the Contributor License Agreement! |
@@ -113,6 +115,11 @@ protected TcpConnectionSupport buildNewConnection() { | |||
return wrappedConnection; | |||
} | |||
catch (IOException e) { | |||
try { | |||
socketChannel.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to check if socketChannel != null
first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I missed the null check. Thanks for catching that!
@@ -113,6 +115,11 @@ protected TcpConnectionSupport buildNewConnection() { | |||
return wrappedConnection; | |||
} | |||
catch (IOException e) { | |||
try { | |||
socketChannel.close(); | |||
} catch (IOException e2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our code style is to have catch
on a new line.
You can run locally ./gradlew :spring-integration-ip:check
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked the style guide and fixed it accordingly. Thanks for the feedback :)
Fixes: spring-projects#9694 Issue link: spring-projects#9694 - Add null check before closing socketChannel in catch block - Prevents potential NullPointerException during error handling
@anthologia , |
Fixes: #9694
Issue link: #9694