Other |
---|
tbdUnresolved |
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
ADDITIONAL SYSTEM INFORMATION : Issue was also reproduced with Java 1.8.0_221-x64 and Java 11.0.2 A DESCRIPTION OF THE PROBLEM : Given a jar file entry URL When closing the InputStream created by a call to URL.openStream API Then the close method inherited by the java.util.jar.JarFile created by the JDK is not called And an attempt to delete the jar file using Java libraries or Windows Explorer fails with "The process cannot access the file because it is being used by another process." STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : For the below test code, create a the folder D:\temp\jdkbug and copy into it jrt-fs.jar (from the jdk). - One can of course change the directories and adapt the code - There's a huge chance any jar and any entry of that jar will reproduce the issue ---------- BEGIN SOURCE ---------- import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; public class UrlStreamClose { public static void main(String[] args) throws Exception { try (InputStream is = new URL("jar:file:D:/temp/jdkbug/jrt-fs.jar!/META-INF/MANIFEST.MF").openStream()) { System.out.println("hello"); } Files.delete(Paths.get("D:\\temp\\jdkbug\\jrt-fs.jar")); } } ---------- END SOURCE ---------- FREQUENCY : always
|