From 85e2b3a01c2869c6e3497c97fefd4f67d60306db Mon Sep 17 00:00:00 2001 From: Albert Mingkun Yang Date: Wed, 27 May 2026 12:18:06 +0000 Subject: [PATCH] 8385309: Test jdk/jfr/event/gc/collection/TestGCEventMixedWithParallelOld.java failed Reviewed-by: egahlin, aboldtch --- .../jdk/jfr/event/gc/collection/GCEventAll.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/jdk/jdk/jfr/event/gc/collection/GCEventAll.java b/test/jdk/jdk/jfr/event/gc/collection/GCEventAll.java index 023acfb144b..1768779915d 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/GCEventAll.java +++ b/test/jdk/jdk/jfr/event/gc/collection/GCEventAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2026, 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 @@ -166,9 +166,11 @@ public class GCEventAll { List gcBatches = null; GCHelper.CollectionSummary eventCounts = null; - // For some GC configurations, the JFR recording may have stopped before we received the last gc event. + // The first/last GC batch can be incomplete if recording starts before all + // event settings are applied or stops before all events are received. try { - gcBatches = GCHelper.GcBatch.createFromEvents(events); + List completeEvents = GCHelper.removeFirstAndLastGC(events); + gcBatches = GCHelper.GcBatch.createFromEvents(completeEvents); eventCounts = GCHelper.CollectionSummary.createFromEvents(gcBatches); verifyUniqueIds(gcBatches); @@ -244,9 +246,10 @@ public class GCEventAll { } // JFR events and GarbageCollectorMXBean events are not updated at the same time. // This means that number of collections may diff. - // We allow a diff of +- 1 collection count. - long minCount = Math.max(0, beanCounts - 1); - long maxCount = beanCounts + 1; + // We allow a diff of +- 2 collection counts, since the first and last + // GC batches are removed to avoid recording-boundary races. + long minCount = Math.max(0, beanCounts - 2); + long maxCount = beanCounts + 2; Asserts.assertGreaterThanOrEqual(eventCounts, minCount, "Too few event counts for collector " + collector); Asserts.assertLessThanOrEqual(eventCounts, maxCount, "Too many event counts for collector " + collector); }