Skip to content

Commit 3c72c04

Browse files
committed
8350818: Improve OperatingSystemMXBean cpu load tests to not accept -1.0 by default
Reviewed-by: kevinw
1 parent 6b719ee commit 3c72c04

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

test/jdk/com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* 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 {
3939
double load;
4040
for(int i=0; i<10; i++) {
4141
load = mbean.getProcessCpuLoad();
42-
if((load<0.0 || load>1.0) && load != -1.0) {
42+
if(load<0.0 || load>1.0) {
4343
throw new RuntimeException("getProcessCpuLoad() returns " + load
4444
+ " which is not in the [0.0,1.0] interval");
4545
}

test/jdk/com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
2424
/*
2525
* @test
2626
* @bug 7028071
27-
* @summary Basic unit test of OperatingSystemMXBean.getProcessCpuLoad()
27+
* @summary Basic unit test of OperatingSystemMXBean.getSystemCpuLoad()
2828
*
2929
* @run main GetSystemCpuLoad
3030
*/
@@ -39,7 +39,7 @@ public static void main(String[] argv) throws Exception {
3939
double load;
4040
for(int i=0; i<10; i++) {
4141
load = mbean.getSystemCpuLoad();
42-
if((load<0.0 || load>1.0) && load != -1.0) {
42+
if(load<0.0 || load>1.0) {
4343
throw new RuntimeException("getSystemCpuLoad() returns " + load
4444
+ " which is not in the [0.0,1.0] interval");
4545
}

0 commit comments

Comments
 (0)