Skip to content

Commit e89c129

Browse files
committed
8374181: failure_handler: The cores.html file is formatted incorrectly and so hides the core dump information
Reviewed-by: erikj
1 parent 15b7a42 commit e89c129

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
import com.sun.javatest.regtest.config.RegressionParameters;
3030
import jdk.test.failurehandler.*;
3131

32-
import java.io.File;
3332
import java.io.FileWriter;
3433
import java.io.IOException;
3534
import java.io.PrintWriter;
3635
import java.nio.file.Files;
3736
import java.nio.file.Path;
3837
import java.nio.file.Paths;
38+
import java.util.List;
39+
import java.util.stream.Stream;
3940

4041
/**
4142
* The jtreg test execution observer, which gathers info about
@@ -85,11 +86,15 @@ public void finishedTest(TestResult tr) {
8586
testJdk, compileJdk);
8687
gatherEnvInfo(workDir, name, log,
8788
gathererFactory.getEnvironmentInfoGatherer());
88-
Files.walk(workDir)
89-
.filter(Files::isRegularFile)
90-
.filter(f -> (f.getFileName().toString().contains("core") || f.getFileName().toString().contains("mdmp")))
91-
.forEach(core -> gatherCoreInfo(workDir, name,
92-
core, log, gathererFactory.getCoreInfoGatherer()));
89+
// generate a cores.html file after parsing the core dump files (if any)
90+
List<Path> coreFiles;
91+
try (Stream<Path> paths = Files.walk(workDir)) {
92+
coreFiles = paths.filter(Files::isRegularFile)
93+
.filter(f -> (f.getFileName().toString().contains("core")
94+
|| f.getFileName().toString().contains("mdmp")))
95+
.toList();
96+
}
97+
gatherCoreInfo(workDir, name, coreFiles, log, gathererFactory.getCoreInfoGatherer());
9398
} catch (Throwable e) {
9499
log.printf("ERROR: exception in observer %s:", name);
95100
e.printStackTrace(log);
@@ -103,16 +108,22 @@ public void finishedTest(TestResult tr) {
103108
}
104109
}
105110

106-
private void gatherCoreInfo(Path workDir, String name, Path core, PrintWriter log,
107-
CoreInfoGatherer gatherer) {
111+
private void gatherCoreInfo(Path workDir, String name, List<Path> coreFiles,
112+
PrintWriter log, CoreInfoGatherer gatherer) {
113+
if (coreFiles.isEmpty()) {
114+
return;
115+
}
108116
try (HtmlPage html = new HtmlPage(workDir, CORES_OUTPUT, true)) {
109117
try (ElapsedTimePrinter timePrinter
110118
= new ElapsedTimePrinter(new Stopwatch(), name, log)) {
111-
gatherer.gatherCoreInfo(html.getRootSection(), core);
119+
// gather information from the contents of each core file
120+
for (Path coreFile : coreFiles) {
121+
gatherer.gatherCoreInfo(html.getRootSection(), coreFile);
122+
}
112123
}
113124
} catch (Throwable e) {
114-
log.printf("ERROR: exception in observer on getting environment "
115-
+ "information %s:", name);
125+
log.printf("ERROR: exception in %s observer while gathering information from"
126+
+ " core dump file", name);
116127
e.printStackTrace(log);
117128
}
118129
}

0 commit comments

Comments
 (0)