Avoid file leak in RemoteExtensionLoader #502
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This problem was found as part of arquillian/arquillian-extension-warp#131 - full details see there.
When deploying a test using arquillian-extension-warp to GlassFish 4.1 or newer running on a Windows machine (no problem on linux), all Jars that are inside "WEB-INF\lib" of the deployed app are locked and the app has a long delay until GlassFish performs the "undeploy" operation.
Using File Leak Detector, I found that
org.jboss.arquillian.container.test.impl.RemoteExtensionLoader
is one of the culprits for this leak:URL.openStream
creates ajava.net.JarConnection
that caches opened files by default.As those files are accessed only once in Arquillian, there is no performance reason to cache them.
This pull request switches off caching and closed the file afterwards.
Unfortunately, this does not help against the undeploy problems, because GlassFish seems to have a bug, and another piece of code also does not close the file properly. Hopefully, this was fixed with GlassFish 6, but I cannot test it, as "arquillian-extension-warp" would have to be updated to JakartaEE first.
WildFly is not affected by this problem because of the underlying VFS implementation. But GlassFish accesses the files directly.