Skip to content

KNOX-3138 implemented try-with-resources for Closeables #1033

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dk2k
Copy link

@dk2k dk2k commented Apr 28, 2025

KNOX-3138 implemented try-with-resources for Closeables (prevents resource leaks)
Closeables need to be closed properly and the native way is try-with-resources.
I haven't executed any tests for one simple reason: if the changed code is buildable, I don't expect any issues (It's not the first time when I implement try-with-resources)
As you can see, all checks are green.

I wish I could provide more details.

@lmccay
Copy link
Contributor

lmccay commented Apr 28, 2025

Hi @dk2k - Thank you for your contribution! While we wait for the checks to pass, can you please revisit the PR description to follow the template that we provide for contributions? That level of detail is important for reviews. Thanks again!

@lmccay
Copy link
Contributor

lmccay commented May 8, 2025

KNOX-3138 implemented try-with-resources for Closeables (prevents resource leaks) Closeables need to be closed properly and the native way is try-with-resources. I haven't executed any tests for one simple reason: if the changed code is buildable, I don't expect any issues (It's not the first time when I implement try-with-resources) As you can see, all checks are green.

I wish I could provide more details.

@dk2k - I'd like to better understand your motivation for making this change. Did you encounter an issue with them not being closed? If so, have to tried this and observed it being addressed?

Otherwise, I'd like to understand how you determined that you wanted to make this change.

@dk2k
Copy link
Author

dk2k commented May 8, 2025

@lmccay try-with-resources (TwR) was introduced exactly for these cases. If a closeable has a non-empty close() method, it should be called. Of course, you can call close() explicitly, but it's boilerplate code.
I found this issue with static analysis tool.
From my experience: if code is buildable after such changes, it means the changes are safe.

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