Skip to content

Commit 444a0d9

Browse files
committedJun 15, 2022
8284977: MetricsTesterCgroupV2.getLongValueEntryFromFile fails when named value doesn't exist
Reviewed-by: sgehwolf, mdoerr
1 parent 08400f1 commit 444a0d9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎test/lib/jdk/test/lib/containers/cgroup/MetricsTesterCgroupV2.java

+5
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ private long getLongValueEntryFromFile(String file, String metric) {
121121
Path filePath = Paths.get(UNIFIED.getPath(), file);
122122
try {
123123
String strVal = Files.lines(filePath).filter(l -> l.startsWith(metric)).collect(Collectors.joining());
124+
if (strVal.isEmpty()) {
125+
// sometimes the match for the metric does not exist, e.g. cpu.stat's nr_periods iff the controller
126+
// is not enabled
127+
return UNLIMITED;
128+
}
124129
String[] keyValues = strVal.split("\\s+");
125130
String value = keyValues[1];
126131
return convertStringToLong(value);

0 commit comments

Comments
 (0)
Please sign in to comment.