Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8284977: MetricsTesterCgroupV2.getLongValueEntryFromFile fails when n…
…amed value doesn't exist

Backport-of: 444a0d98ac06ab043e3b11281234fd515abff302
  • Loading branch information
kurashige23 authored and jerboaa committed Dec 23, 2022
1 parent b4ef3d3 commit b4a745d
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -121,6 +121,11 @@ 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());
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
return UNLIMITED;
}
String[] keyValues = strVal.split("\\s+");
String value = keyValues[1];
return convertStringToLong(value);
Expand Down

1 comment on commit b4a745d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.