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

Ensure PackedFile is always closed and remove PackedFile.finalize() #4226

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Jul 31, 2023

Identify the Bug or Feature request

Implements #3948

Description of the Change

Almost all PackedFile instances are wrapped in a try-with-resources to ensure they are always closed. The one exception (PersistenceUtils.saveCampaign()) had logic around .close(), so I left that in its finally block instead of trying to rework it into try-with-resources.

Possible Drawbacks

Should be none.

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

Almost all `PackedFile` instances are wrapped in a try-with-resources to ensure they are always closed. The one
exception guarantees the instance is closed in a `finally` block.

The following places used to (at least partially) rely on PackedFile.finalize() but now use try-with-resources:
- `ImageFileImagePanelModel.getDecorations()`
- `PersistenceUtils.loadCampaignProperties()`
- `PackedFile`

The following place used to call `PackedFile.close()` in a `finally` block now uses try-with-resources:
- `PersistenceUtil.loadCampaign()`

The following place still uses a `finally` block because there is extra logic surrounding the close() call:
- `PersistenceUtil.saveCampaign()`
@cwisniew cwisniew added this pull request to the merge queue Aug 1, 2023
Merged via the queue into RPTools:develop with commit b570021 Aug 1, 2023
4 checks passed
@cwisniew cwisniew added the code-maintenance Adding/editing javadocs, unit tests, formatting. label Aug 2, 2023
@kwvanderlinde kwvanderlinde deleted the refactor/3948-remove-finalize branch August 31, 2023 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-maintenance Adding/editing javadocs, unit tests, formatting.
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[Refactoring]: PackedFile overrides the finalize method which is deprecated and marked for removal.
2 participants