Skip to content

Fix 'Resource leak: <variable> is never closed' warnings #2023

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 2 commits into from
Aug 19, 2025

Conversation

kcooney
Copy link
Contributor

@kcooney kcooney commented Aug 2, 2025

Fix numerous places where using AutoCloseable objects without closing them.

Changes:

  • Upgrade JUnit from 5.10.0 to 5.11.4 (so @AutoClose can be used)
  • Use Files.copy() to copy files
  • Use try-with-resources when calling Files.list() or Files.walk()
  • Use try-with-resources or @AutoClose to close PhotonCamera and
    PhotonCameraSim objects created by tests
  • Update SQLConfigTest to use @TempDir

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1
  • If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated
  • If this PR addresses a bug, a regression test for it is added

@kcooney kcooney requested a review from a team as a code owner August 2, 2025 23:29
@kcooney kcooney marked this pull request as draft August 2, 2025 23:56
@kcooney kcooney force-pushed the fix-auto-closeable-resource-leaks branch 2 times, most recently from 123b881 to 68cf4e9 Compare August 3, 2025 00:57
@kcooney kcooney marked this pull request as ready for review August 3, 2025 01:49
@samfreund samfreund added bug Something isn't working backend Things relating to photon-core and photon-server labels Aug 4, 2025
@kcooney kcooney force-pushed the fix-auto-closeable-resource-leaks branch from 68cf4e9 to ac732d6 Compare August 7, 2025 17:20
@github-actions github-actions bot added the photonlib Things related to the PhotonVision library label Aug 7, 2025
Changes:
- Upgrade JUnit from 5.10.0 to 5.11.4 (so @autoclose can be used)
- Use Files.copy() to copy files
- Use try-with-resources when calling Files.list() or Files.walk()
- Use try-with-resources or @autoclose to close PhotonCamera and
  PhotonCameraSim objects created by tests
- Use try-with-resources when calling AprilTag.generate36h11AprilTagImage()
- Update SQLConfigTest to use @tempdir
@kcooney kcooney force-pushed the fix-auto-closeable-resource-leaks branch from ac732d6 to 2a40b18 Compare August 18, 2025 02:50
@kcooney
Copy link
Contributor Author

kcooney commented Aug 18, 2025

FYI: rebased the branch off of main

Gold856
Gold856 previously approved these changes Aug 19, 2025
@Gold856 Gold856 enabled auto-merge (squash) August 19, 2025 01:20
auto-merge was automatically disabled August 19, 2025 01:36

Head branch was pushed to by a user without write access

@kcooney kcooney force-pushed the fix-auto-closeable-resource-leaks branch from 49c4e12 to 7d622c2 Compare August 19, 2025 01:36
@Gold856 Gold856 merged commit 7d927ac into PhotonVision:main Aug 19, 2025
50 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Things relating to photon-core and photon-server bug Something isn't working photonlib Things related to the PhotonVision library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants