From 13731a5733aeebc7d7c09e52f0ecd28b0fabb4b1 Mon Sep 17 00:00:00 2001 From: MBaesken Date: Thu, 9 Jan 2025 16:10:22 +0100 Subject: [PATCH] JDK-8347267 --- .../macosx/native/libmanagement_ext/UnixOperatingSystem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c index 2c11cd9ca9d8d..269c4d4535909 100644 --- a/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c +++ b/src/jdk.management/macosx/native/libmanagement_ext/UnixOperatingSystem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2020, 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 @@ -63,6 +63,9 @@ Java_com_sun_management_internal_OperatingSystemImpl_getCpuLoad0 jlong used_delta = used - last_used; jlong total_delta = total - last_total; + if (total_delta == 0) { + return 0; + } jdouble cpu = (jdouble) used_delta / total_delta;