Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix failing to delete temporary remapping files #935

Closed
wants to merge 2 commits into from

Conversation

tomwmth
Copy link

@tomwmth tomwmth commented Jun 8, 2024

Fixes #920

Not sure how to unit test this but I am open to suggestions

tomwmth added 2 commits June 6, 2024 14:46
This exact method is called twice later in this same function and always with a try-with-resources. Update this occurrence to match rather than use an explicit close call.
JarURLConnection contains internal caching of opened JARs. This causes the JVM to maintain a handle to any JAR file accessed this way.

Said handle remains open until the cache invalidates or the JVM terminates. In the case of a short-lived program such as Fabric Loader, it is usually JVM termination. This prevents us from deleting the temporary remapping files after reading it's manifest.

Since this cache is theoretically useful in the context of Log4jLogHandler, leave it up to the caller to decide whether or not it should be bypassed.
@tomwmth
Copy link
Author

tomwmth commented Jun 8, 2024

As discussed in the issue, I believe it might be a good idea to simply remove (or empty) the tmp directory used for remapping (if it exists) whenever the remapping begins.

There is no attempt made to reuse these temporary files, nor do I think there should be. However this means if deletion ever fails for whatever reason (e.g. process terminated early) the files are now permanently there unless manually deleted by the user. The directory can be safely removed whenever remapping begins to ensure any stray temporary files from previous executions are deleted.

@modmuss50 modmuss50 self-requested a review June 8, 2024 14:09
@modmuss50 modmuss50 added this to the 0.16.0 milestone Jun 8, 2024
@modmuss50
Copy link
Member

Superseeded by: #936 thanks for the PR.

@modmuss50 modmuss50 closed this Jul 9, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to delete temporary remapping file for any nested JAR in development environment
2 participants