diff -r d284ff23fa4c -r 8a8fd35b6bc6 test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java Mon Sep 30 15:35:56 2019 +0200 +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestRemovedChunks.java Mon Sep 30 20:52:58 2019 +0200 @@ -28,6 +28,7 @@ import java.util.concurrent.CountDownLatch; import jdk.jfr.Event; +import jdk.jfr.Recording; import jdk.jfr.consumer.RecordingStream; /** @@ -60,7 +61,7 @@ public static void main(String... args) throws Exception { try (RecordingStream s = new RecordingStream()) { - s.setMaxSize(20_000_000); + s.setMaxSize(5_000_000); s.onEvent(ParkStream.class.getName(), e -> { parkLatch.countDown(); await(removalLatch); @@ -70,18 +71,26 @@ IFeelFineLatch.countDown(); }); s.startAsync(); - emitData(15_000_000); + // Fill first chunk with data + emitData(1_000_000); + // Park stream ParkStream ps = new ParkStream(); ps.commit(); await(parkLatch); - // Try to force removal of chunk that is being streamed - emitData(50_000_000); - removalLatch.countDown(); + // Rotate and emit data that exceeds maxSize + for (int i = 0; i< 10;i++) { + try (Recording r = new Recording()) { + emitData(1_000_000); + } + } + // Emit final event IFeelFine i = new IFeelFine(); i.commit(); + // Wake up parked stream + removalLatch.countDown(); + // Await event things gone bad await(IFeelFineLatch); } - } private static void await(CountDownLatch latch) throws Error {