From e89c1290ca8b3e07bef12f4c0465c3e83389fef4 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Tue, 13 Jan 2026 01:29:20 +0000 Subject: [PATCH] 8374181: failure_handler: The cores.html file is formatted incorrectly and so hides the core dump information Reviewed-by: erikj --- .../jtreg/GatherDiagnosticInfoObserver.java | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java index e63e55888d7..32dbedb5159 100644 --- a/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java +++ b/test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java @@ -29,13 +29,14 @@ import com.sun.javatest.TestResult; import com.sun.javatest.regtest.config.RegressionParameters; import jdk.test.failurehandler.*; -import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Stream; /** * The jtreg test execution observer, which gathers info about @@ -85,11 +86,15 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer { testJdk, compileJdk); gatherEnvInfo(workDir, name, log, gathererFactory.getEnvironmentInfoGatherer()); - Files.walk(workDir) - .filter(Files::isRegularFile) - .filter(f -> (f.getFileName().toString().contains("core") || f.getFileName().toString().contains("mdmp"))) - .forEach(core -> gatherCoreInfo(workDir, name, - core, log, gathererFactory.getCoreInfoGatherer())); + // generate a cores.html file after parsing the core dump files (if any) + List coreFiles; + try (Stream paths = Files.walk(workDir)) { + coreFiles = paths.filter(Files::isRegularFile) + .filter(f -> (f.getFileName().toString().contains("core") + || f.getFileName().toString().contains("mdmp"))) + .toList(); + } + gatherCoreInfo(workDir, name, coreFiles, log, gathererFactory.getCoreInfoGatherer()); } catch (Throwable e) { log.printf("ERROR: exception in observer %s:", name); e.printStackTrace(log); @@ -103,16 +108,22 @@ public class GatherDiagnosticInfoObserver implements Harness.Observer { } } - private void gatherCoreInfo(Path workDir, String name, Path core, PrintWriter log, - CoreInfoGatherer gatherer) { + private void gatherCoreInfo(Path workDir, String name, List coreFiles, + PrintWriter log, CoreInfoGatherer gatherer) { + if (coreFiles.isEmpty()) { + return; + } try (HtmlPage html = new HtmlPage(workDir, CORES_OUTPUT, true)) { try (ElapsedTimePrinter timePrinter = new ElapsedTimePrinter(new Stopwatch(), name, log)) { - gatherer.gatherCoreInfo(html.getRootSection(), core); + // gather information from the contents of each core file + for (Path coreFile : coreFiles) { + gatherer.gatherCoreInfo(html.getRootSection(), coreFile); + } } } catch (Throwable e) { - log.printf("ERROR: exception in observer on getting environment " - + "information %s:", name); + log.printf("ERROR: exception in %s observer while gathering information from" + + " core dump file", name); e.printStackTrace(log); } }