Skip to content
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

Properly close sources from files #351

Merged

Conversation

mdedetrich
Copy link
Contributor

@mdedetrich mdedetrich commented Jan 24, 2025

Intellij picked this up when inspecting the codebase, there are a lot of cases of creating a BufferedSource from a file using scala.io.Source but not properly closing the file in all cases (i.e. if there is an exception) which can lead to file handle leaks.

As another improvement, we use scala.util.control.NonFatal since when you catch exceptions you should only be catching the ones that make sense to catch.

@mdedetrich mdedetrich force-pushed the properly-close-source-files branch from 128ebfd to 6284495 Compare January 24, 2025 12:49
Copy link
Member

@rolandtritsch rolandtritsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdedetrich Good one. Good code hygene. Thank you.

@rolandtritsch rolandtritsch merged commit fc7fe9b into scoverage:main Jan 24, 2025
5 checks passed
@rolandtritsch
Copy link
Member

@mdedetrich Did also cut a new release to make the improvements available to everybody.

@mdedetrich mdedetrich deleted the properly-close-source-files branch January 24, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants