On Wed, 30 Apr 2025 17:44:13 GMT, Chris Plummer <cjplum...@openjdk.org> wrote:
>> This is hard to reproduce, and at first I'd only seen -1 returned on the >> first calls to mbean.getProcessCpuLoad(). >> But eventually I observed a -1 at any time, including in middle of the >> iterations, or on the last iteration which makes the current test fail. >> >> Should fail on Windows only if we only ever see -1 returned from >> getProcessCpuLoad(). >> Remove the "exclusiveAccess.dirs=." (JDK-8353231 adding >> "exclusiveAccess.dirs=." did not fix this.) > > test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java line > 69: > >> 67: } >> 68: >> 69: if (good == 0 && ex != null) { > > The check for `ex != null` is not necessary. It should always be set if `good > == 0` Right, it does not really need to set ex = null as as soon as there is something in "good", we pass. But leaving the Exception hanging around seems wrong. If good is zero then yes checking for ex is redundant. I left the check mostly to avoid any future change breaking it, but maybe it's best to expose that and make sure we fail if good is zero. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/24961#discussion_r2069234063