-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fix code smells #175
Fix code smells #175
Conversation
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.
Looks good, thanks for tracking these down! Two lines can optionally be deleted with the new changes.
outputFile.getParentFile().mkdirs(); | ||
NotifyingIOUtils.copy(inputStream, bos, | ||
new Progress(outputFile, current.getSize())); | ||
IOUtils.closeQuietly(inputStream); |
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.
Are the two closeQuietly
calls still needed? close()
is implicitly called by the try-with-resource block.
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.
I weighed removing them, then decided not to, to avoid changing the behavior. In this case, close quietly would close it and not return an exception if it fails closing. The question is would it fail again anyway once the implicit finally block tries to close it again...? In which case I can remove those calls.
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.
Hmm good point. Maybe worth testing with and without the calls.
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.
Ok, let me add a unit test
Fixing those code smells from the sonar report:
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg5Cbl6vpliCeK6yK&open=AWSBg5Cbl6vpliCeK6yK
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg5E3l6vpliCeK60I&open=AWSBg5E3l6vpliCeK60I
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg4zyl6vpliCeK6qK&open=AWSBg4zyl6vpliCeK6qK
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg4zyl6vpliCeK6qL&open=AWSBg4zyl6vpliCeK6qL
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg489l6vpliCeK6t2&open=AWSBg489l6vpliCeK6t2
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg489l6vpliCeK6t3&open=AWSBg489l6vpliCeK6t3
https://sonarcloud.io/project/issues?id=org.openstreetmap.atlas%3Aatlas&issues=AWSBg5BHl6vpliCeK6wH&open=AWSBg5BHl6vpliCeK6wH