From 3c72c04de7a43d265dae7160fe53baaaa8ae6f73 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Fri, 28 Feb 2025 22:37:41 +0000 Subject: [PATCH] 8350818: Improve OperatingSystemMXBean cpu load tests to not accept -1.0 by default Reviewed-by: kevinw --- .../management/OperatingSystemMXBean/GetProcessCpuLoad.java | 4 ++-- .../management/OperatingSystemMXBean/GetSystemCpuLoad.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java b/test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java index bbf26e099f3..ecb65b7b3ea 100644 --- a/test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java +++ b/test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ public static void main(String[] argv) throws Exception { double load; for(int i=0; i<10; i++) { load = mbean.getProcessCpuLoad(); - if((load<0.0 || load>1.0) && load != -1.0) { + if(load<0.0 || load>1.0) { throw new RuntimeException("getProcessCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); } diff --git a/test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java b/test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java index 71ee209258a..7bd9d162cb3 100644 --- a/test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java +++ b/test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * @test * @bug 7028071 - * @summary Basic unit test of OperatingSystemMXBean.getProcessCpuLoad() + * @summary Basic unit test of OperatingSystemMXBean.getSystemCpuLoad() * * @run main GetSystemCpuLoad */ @@ -39,7 +39,7 @@ public static void main(String[] argv) throws Exception { double load; for(int i=0; i<10; i++) { load = mbean.getSystemCpuLoad(); - if((load<0.0 || load>1.0) && load != -1.0) { + if(load<0.0 || load>1.0) { throw new RuntimeException("getSystemCpuLoad() returns " + load + " which is not in the [0.0,1.0] interval"); }