diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index b33a8943042..bb2c8207cfe 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -679,4 +679,8 @@ public synchronized void migrate(SafePath repo) throws IOException { public RepositoryChunk getCurrentChunk() { return currentChunk; } + + public synchronized void flush() { + MetadataRepository.getInstance().flush(); + } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java index 407bdadad43..739f32bf634 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/periodic/FlushTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -26,6 +26,8 @@ import jdk.jfr.internal.JVM; import jdk.jfr.internal.MetadataRepository; +import jdk.jfr.internal.PlatformRecorder; +import jdk.jfr.internal.PrivateAccess; import jdk.jfr.internal.util.Utils; /** @@ -44,7 +46,8 @@ public FlushTask() { @Override public void execute(long timestamp, PeriodicType periodicType) { - MetadataRepository.getInstance().flush(); + PlatformRecorder recorder = PrivateAccess.getInstance().getPlatformRecorder(); + recorder.flush(); Utils.notifyFlush(); }