8380755: jdk/jfr/event/gc/heapsummary/TestHeapSummaryEventG1.java fails gcId should be increasing

Reviewed-by: dholmes, mgronlun
This commit is contained in:
Erik Gahlin 2026-04-08 12:19:07 +00:00
parent 28a91d0e3a
commit cc1c427f47
2 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2025, 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
@ -48,7 +48,7 @@ public class HeapSummaryEventAllGcs {
GCHelper.callSystemGc(5, true);
recording.stop();
List<RecordedEvent> allEvents = Events.fromRecording(recording);
List<RecordedEvent> allEvents = Events.fromRecordingOrdered(recording);
if (!checkCollectors(allEvents, expectedYoungCollector, expectedOldCollector)) {
return;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2025, 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
@ -33,6 +33,7 @@ import java.io.IOException;
import java.nio.file.Path;
import java.time.Duration;
import java.time.Instant;
import java.util.Comparator;
import java.util.List;
import jdk.jfr.AnnotationElement;
@ -280,6 +281,20 @@ public class Events {
return RecordingFile.readAllEvents(makeCopy(recording));
}
/**
* Creates a list of events from a recording, ordered by the end time.
*
* @param recording recording, not {@code null}
* @return a list, not null
* @throws IOException if an event set could not be created due to I/O
* errors.
*/
public static List<RecordedEvent> fromRecordingOrdered(Recording recording) throws IOException {
List<RecordedEvent> events = fromRecording(recording);
events.sort(Comparator.comparing(RecordedEvent::getEndTime));
return events;
}
public static RecordingFile copyTo(Recording r) throws IOException {
return new RecordingFile(makeCopy(r));
}