RFR: 8132359 - JarURLConnection.getJarFile() resource leak when file is not found

Rob McKenna rob.mckenna at oracle.com
Sun Nov 24 15:33:17 UTC 2019


Hi folks,

If a FileNotFoundException is thrown when attempting to load a class
from a jar file, a reference to the open JarFile remains even after the
loader is closed. The test in the webrev demonstrates the problem by
attempting to delete the JarFile after attempting a class load.

The deletion will fail as the JarFile is still in use (i.e. open)
despite the fact that the loader has been closed.

Note: the behaviour depends on the URLConnections useCaches setting so
the test cycles through the combinations. (this helpfully found a problem
with an earlier fix attempt)

bug: https://bugs.openjdk.java.net/browse/JDK-8132359
webrev: http://cr.openjdk.java.net/~robm/8132359/webrev.01/

Thanks,

    -Rob



More information about the net-dev mailing list