Skip to content

Fix archivePathToZip cache and FoundFile #1

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: develop
Choose a base branch
from

Conversation

t1mlange
Copy link
Owner

@t1mlange t1mlange commented Feb 9, 2024

The old implementation had multiple issues. First, the reference counting was exposed to the user, and surprise, it was not used correctly. Second, with correct reference counting, the cache did not evict unused resources but instead returned also already closed resources. And last, even if both issues are fixed, the reference count needs to be performed atomically with the cache eviction, which is not really possible with guava.

This patch tries to keep track of shared resources transparently. Each retrieval from the cache increases the ref count and each close on the shared resource decreases the ref count. Assuming the user uses try-resources, this should fix all the issues above.

The old implementation had multiple issues. First, the reference
counting was exposed to the user, and surprise, it was not used
correctly. Second, with correct reference counting, the cache did not
evict unused but instead returned also already closed resources. And
last, even if both issues are fixed, the reference count needs to be
performed with the cache eviction, otherwise one might acquire the
resource in between the decrement and eviction.

This patch tries to keep track of shared resources transparently. Each
retrieval from the cache increases the ref count and each close on the
shared resource decreases the ref count. Assuming the user uses
try-resources, this should fix all the issues above.
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.

1 participant