From 0d5b44a98a2a01093d5097effe68819dd5e58325 Mon Sep 17 00:00:00 2001 From: Yude Lin Date: Sun, 4 Feb 2024 15:34:28 +0800 Subject: [PATCH] [GC] Fix a test failure on G1 Concurrent GC MXBean (#789) Summary: G1 Concurrent GC only monitors G1 Old Gen Testing: hotspot/jtreg Reviewers: mmyxym, weixlu Issue: https://github.com/dragonwell-project/dragonwell11/issues/790 --- .../GarbageCollectionNotificationContentTest.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/jdk/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java b/test/jdk/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java index ac2ef2598be..f37418371b3 100644 --- a/test/jdk/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java +++ b/test/jdk/com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationContentTest.java @@ -154,7 +154,11 @@ private static void checkGarbageCollectionNotificationInfoContent(GarbageCollect System.out.println(" Before GC: " + busage); System.out.println(" After GC: " + ausage); - checkMemoryUsage(poolname, busage, ausage); + String checkedPoolName = "Eden Space"; + if ("G1 Concurrent GC".equals(notif.getGcName())) { + checkedPoolName = "G1 Old Gen"; + } + checkMemoryUsage(poolname, checkedPoolName, busage, ausage); } // check if memory usage for all memory pools are returned @@ -167,11 +171,12 @@ private static void checkGarbageCollectionNotificationInfoContent(GarbageCollect } } - private static void checkMemoryUsage(String poolname, MemoryUsage busage, MemoryUsage ausage) throws Exception { - if (poolname.contains("Eden Space") && busage.getUsed() > 0) { - // Used size at Eden Space should be decreased or + private static void checkMemoryUsage(String poolname, String checkedPoolName, + MemoryUsage busage, MemoryUsage ausage) throws Exception { + if (poolname.contains(checkedPoolName) && busage.getUsed() > 0) { + // Used size at the checked pool should be decreased or if (busage.getUsed() <= ausage.getUsed()) { - throw new RuntimeException("Used size at Eden Space should be decreased."); + throw new RuntimeException("Used size at " + checkedPoolName + " should be decreased."); } } }