Skip to content

Commit

Permalink
8350818: Improve OperatingSystemMXBean cpu load tests to not accept -…
Browse files Browse the repository at this point in the history
…1.0 by default

Reviewed-by: kevinw
  • Loading branch information
lmesnik committed Feb 28, 2025
1 parent 6b719ee commit 3c72c04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,7 +24,7 @@
/*
* @test
* @bug 7028071
* @summary Basic unit test of OperatingSystemMXBean.getProcessCpuLoad()
* @summary Basic unit test of OperatingSystemMXBean.getSystemCpuLoad()
*
* @run main GetSystemCpuLoad
*/
Expand All @@ -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");
}
Expand Down

0 comments on commit 3c72c04

Please sign in to comment.