8374200: jdk/internal/platform/cgroup/TestCgroupMetrics.java fails with common prefix metrics

Reviewed-by: dholmes
This commit is contained in:
Jie Fu 2025-12-23 14:31:29 +00:00
parent 40755afdf9
commit f1c50412f0

View File

@ -121,7 +121,8 @@ public class MetricsTesterCgroupV2 implements CgroupMetricsTester {
private long getLongValueEntryFromFile(String file, String metric) {
Path filePath = Paths.get(UNIFIED.getPath(), file);
try {
String strVal = Files.lines(filePath).filter(l -> l.startsWith(metric)).collect(Collectors.joining());
String strVal = Files.lines(filePath)
.filter(l -> l.matches("^" + metric + "\\s+.*")).collect(Collectors.joining());
if (strVal.isEmpty()) {
// sometimes the match for the metric does not exist, e.g. cpu.stat's nr_periods iff the controller
// is not enabled