Conversation
srh
reviewed
Feb 21, 2022
| socket.getInetAddress().getHostAddress(), | ||
| socket.getPort(), | ||
| true); | ||
| try ( |
Contributor
There was a problem hiding this comment.
It seems the existing code just creates an SSLSocket and then lets it get GC'd without closing it, assigning inputStream and outputStream instead. I guess the underlying socket does get closed later.
Right now I think we don't want this try block which closes the sslSocket at the end of the block. Why would we close() the sslSocket after constructing streams from it? Wouldn't those streams stop working?
I think we'd want sslSocket to be assigned to a member variable such that its lifetime is held alive as long as the streams exist.
I'll need to investigate what's going on a little bit further before merging this PR. So right now I'm leaving this open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reason for the change
Code smell is important for better readability
Description
I replaced stuff which can be expressed with isEmpty(). And a try with resource for closing the socket if exception gets thrown
Code examples
I replaced
raw.size() == 0withraw.isEmpty()more important is the try with resource of the socket.
old code:
new code:
Checklist
References
Anything else related to the change e.g. documentations, RFCs, etc.