From afda8fbf0bcea18cbe741e9c693789ebe0c6c4c5 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Wed, 8 Mar 2023 08:20:27 +0000 Subject: [PATCH] 8303136: MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded005 failed with "isCollectionUsageThresholdExceeded() returned true, while threshold = 1 and used = 0" Reviewed-by: cjplummer, sspitsyn --- .../isexceeded001.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java index 5dd252db244..702a5a79379 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/MemoryPoolMBean/isCollectionUsageThresholdExceeded/isexceeded001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2023, 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 @@ -120,15 +120,11 @@ public class isexceeded001 { isExceeded = monitor.isCollectionThresholdExceeded(pool); if (!isExceeded) { - // Refresh the values - threshold = monitor.getCollectionThreshold(pool); - usage = monitor.getCollectionUsage(pool); - if (used >= threshold) { - log.complain("isCollectionUsageThresholdExceeded() " - + "returned false, while threshold = " - + threshold + " and " + "used = " + used); - testFailed = true; - } + // Don't refresh the values: usage may have decreased outside our control. + log.complain("isCollectionUsageThresholdExceeded() " + + "returned false, while threshold = " + + threshold + " and " + "used = " + used); + testFailed = true; } } else { log.display(" used value (" + used + ") did not cross the " @@ -137,9 +133,10 @@ public class isexceeded001 { isExceeded = monitor.isCollectionThresholdExceeded(pool); if (isExceeded) { - // Refresh the values + // Refresh the values: usage may have increased outside our control. threshold = monitor.getCollectionThreshold(pool); usage = monitor.getCollectionUsage(pool); + used = usage.getUsed(); if (used < threshold) { log.complain("isCollectionUsageThresholdExceeded() " + "returned true, while threshold = "