8178913: CTW library does not close all opened resources
Reviewed-by: kvn
This commit is contained in:
parent
79793e9c64
commit
154b7f24cb
@ -54,8 +54,7 @@ public class ClassPathJarEntry extends PathHandler {
|
||||
if (!Files.exists(root)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JarFile jarFile = new JarFile(root.toFile());
|
||||
try (JarFile jarFile = new JarFile(root.toFile())) {
|
||||
JarEntry entry;
|
||||
for (Enumeration<JarEntry> e = jarFile.entries();
|
||||
e.hasMoreElements(); ) {
|
||||
|
@ -54,8 +54,7 @@ public class ClassPathJimageEntry extends PathHandler {
|
||||
if (!Files.exists(root)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ImageReader reader = ImageReader.open(root);
|
||||
try (ImageReader reader = ImageReader.open(root)) {
|
||||
Arrays.stream(reader.getEntryNames())
|
||||
.filter(name -> name.endsWith(".class"))
|
||||
.filter(name -> !name.endsWith("module-info.class"))
|
||||
|
@ -90,6 +90,10 @@ public class CompileTheWorld {
|
||||
} catch (Throwable t){
|
||||
t.printStackTrace(ERR);
|
||||
} finally {
|
||||
try {
|
||||
OUT.close();
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
// <clinit> might have started new threads
|
||||
System.exit(passed ? 0 : 1);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.util.Pair;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -145,11 +146,11 @@ public class CtwRunner {
|
||||
}
|
||||
|
||||
private Pair<String, Long> getLastClass(Path errFile) {
|
||||
try {
|
||||
String line = Files.newBufferedReader(errFile)
|
||||
.lines()
|
||||
try (BufferedReader reader = Files.newBufferedReader(errFile)) {
|
||||
String line = reader.lines()
|
||||
.filter(IS_CLASS_LINE)
|
||||
.reduce((a, b) -> b).orElse(null);
|
||||
.reduce((a, b) -> b)
|
||||
.orElse(null);
|
||||
if (line != null) {
|
||||
int open = line.indexOf('[') + 1;
|
||||
int close = line.indexOf(']');
|
||||
|
Loading…
x
Reference in New Issue
Block a user