-
Bug
-
Resolution: Unresolved
-
P4
-
11, 16, 18
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
When jdk.internal.module.ModulePath.readModule(Path, BasicFileAttributes) (called by ModuleFinder) reads a JAR file from a non-default file system, it creates a temporary directory, but never deletes the directory again.
Over time this unnecessarily clutters the temporary directory of the OS.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a ZIP file containing a JAR file
2. Execute the source code provided below with the path of the ZIP file as argument
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All temporary directories, if any, are deleted again.
ACTUAL -
A temporary directory with prefix "mlib" is created and it is not deleted again.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.lang.module.ModuleFinder;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Collections;
class TempDirTest {
public static void main(String... args) throws IOException {
URI pathUri = Path.of(args[0]).toUri();
URI jarUri = URI.create("jar:" + pathUri + "!/");
try (FileSystem fileSystem = FileSystems.newFileSystem(jarUri, Collections.emptyMap())) {
ModuleFinder.of(Path.of(jarUri)).findAll();
}
}
}
---------- END SOURCE ----------
When jdk.internal.module.ModulePath.readModule(Path, BasicFileAttributes) (called by ModuleFinder) reads a JAR file from a non-default file system, it creates a temporary directory, but never deletes the directory again.
Over time this unnecessarily clutters the temporary directory of the OS.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a ZIP file containing a JAR file
2. Execute the source code provided below with the path of the ZIP file as argument
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
All temporary directories, if any, are deleted again.
ACTUAL -
A temporary directory with prefix "mlib" is created and it is not deleted again.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.lang.module.ModuleFinder;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Collections;
class TempDirTest {
public static void main(String... args) throws IOException {
URI pathUri = Path.of(args[0]).toUri();
URI jarUri = URI.create("jar:" + pathUri + "!/");
try (FileSystem fileSystem = FileSystems.newFileSystem(jarUri, Collections.emptyMap())) {
ModuleFinder.of(Path.of(jarUri)).findAll();
}
}
}
---------- END SOURCE ----------