Skip to content

perf: leverage try-with-resources statement when handling input streams #82

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

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

ian-wd
Copy link

@ian-wd ian-wd commented Apr 16, 2025

Context:

  • calling these methods produces LeakedClosableViolation on android StrictMode
  • fix ensures any opened input stream are properly handled and closed

@iBotPeaches iBotPeaches requested a review from Copilot April 16, 2025 12:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a potential resource leak by refactoring the input stream handling to use the try-with-resources statement.

  • Replaces manual resource management with try-with-resources in readFile and read methods
  • Ensures that opened InputStreams are automatically closed to avoid LeakedClosableViolation on Android

@iBotPeaches iBotPeaches requested a review from jyann April 16, 2025 12:09
@iBotPeaches iBotPeaches merged commit 0c10b75 into master Apr 16, 2025
1 check passed
@iBotPeaches iBotPeaches deleted the close-input-stream branch April 16, 2025 13:54
@iBotPeaches iBotPeaches mentioned this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants