Skip to content

Commit

Permalink
8287073: NPE from CgroupV2Subsystem.getInstance()
Browse files Browse the repository at this point in the history
Backport-of: 744b822ab194a0f7ef4e7a4053be32c6a0889efc
  • Loading branch information
jerboaa committed Jun 13, 2022
1 parent 292d90d commit cb88133
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -110,9 +111,9 @@ static CgroupMetrics create() {
Map<String, CgroupInfo> infos = result.getInfos();
if (result.isCgroupV2()) {
// For unified it doesn't matter which controller we pick.
CgroupInfo anyController = infos.get(MEMORY_CTRL);
CgroupSubsystem subsystem = CgroupV2Subsystem.getInstance(anyController);
return subsystem != null ? new CgroupMetrics(subsystem) : null;
CgroupInfo anyController = infos.values().iterator().next();
CgroupSubsystem subsystem = CgroupV2Subsystem.getInstance(Objects.requireNonNull(anyController));
return new CgroupMetrics(subsystem);
} else {
CgroupV1Subsystem subsystem = CgroupV1Subsystem.getInstance(infos);
return subsystem != null ? new CgroupV1MetricsImpl(subsystem) : null;
Expand Down

1 comment on commit cb88133

@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.