Skip to content

Commit

Permalink
8345684: OperatingSystemMXBean.getSystemCpuLoad() throws NPE
Browse files Browse the repository at this point in the history
Backport-of: d7ef3ac
  • Loading branch information
Fabian Meumertzheim authored and jerboaa committed Jan 8, 2025
1 parent 6514d38 commit f117cb0
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,13 @@ public double getProcessCpuLoad() {
}

private boolean isCpuSetSameAsHostCpuSet() {
if (containerMetrics != null && containerMetrics.getCpuSetCpus() != null) {
return containerMetrics.getCpuSetCpus().length == getHostOnlineCpuCount0();
if (containerMetrics != null) {
// The return value may change (including from non-null to null) and
// the call may involve I/O, so keep the result in a local variable.
int[] cpuSetCpus = containerMetrics.getCpuSetCpus();
if (cpuSetCpus != null) {
return cpuSetCpus.length == getHostOnlineCpuCount0();
}
}
return false;
}
Expand Down

0 comments on commit f117cb0

Please sign in to comment.