-
Notifications
You must be signed in to change notification settings - Fork 75
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
Use try with resources for file system #367
Conversation
Any reason for the switch from visitor to stream? |
Nothing major. I think the visitor is not that common nowadays, so streams might make the code easier to read. |
final Path jarPath = fileSystem.getPath(resourcePath); | ||
|
||
try (Stream<Path> stream = Files.walk(jarPath)) { |
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.
final Path jarPath = fileSystem.getPath(resourcePath); | |
try (Stream<Path> stream = Files.walk(jarPath)) { | |
try (Stream<Path> stream = Files.walk(fileSystem.getPath(resourcePath))) { |
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.
You don't use the variable later, so why actually assign it at all?!
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.
You don't use the variable later, so why actually assign it at all?!
Would be nice, but it's actually used (in lines 72 and 77).
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.
So much for my eyesight. 😏
Related to #332 - close file system also in case an exception is thrown. Unlikely to be an actual fix, but at least should rule out earlier failures as a cause.
Also switch from a visitor to a stream.