diff -r de882051f7a5 -r fcad92f425c5 test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java Mon Nov 25 12:34:43 2019 +0100 +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestJVMCrash.java Mon Nov 25 14:06:13 2019 +0100 @@ -42,26 +42,27 @@ */ public class TestJVMCrash { - public static void main(String... args) throws Exception { + public static void main(String... args) throws Exception { int id = 1; while (true) { - TestProcess process = new TestProcess("crash-application-" + id++); - AtomicInteger eventCounter = new AtomicInteger(); - try (EventStream es = EventStream.openRepository(process.getRepository())) { - // Start from first event in repository - es.setStartTime(Instant.EPOCH); - es.onEvent(e -> { - if (eventCounter.incrementAndGet() == TestProcess.NUMBER_OF_EVENTS) { - process.crash(); + try (TestProcess process = new TestProcess("crash-application-" + id++)) { + AtomicInteger eventCounter = new AtomicInteger(); + try (EventStream es = EventStream.openRepository(process.getRepository())) { + // Start from first event in repository + es.setStartTime(Instant.EPOCH); + es.onEvent(e -> { + if (eventCounter.incrementAndGet() == TestProcess.NUMBER_OF_EVENTS) { + process.crash(); + } + }); + es.startAsync(); + // If crash corrupts chunk in repository, retry in 30 seconds + es.awaitTermination(Duration.ofSeconds(30)); + if (eventCounter.get() == TestProcess.NUMBER_OF_EVENTS) { + return; } - }); - es.startAsync(); - // If crash corrupts chunk in repository, retry in 30 seconds - es.awaitTermination(Duration.ofSeconds(30)); - if (eventCounter.get() == TestProcess.NUMBER_OF_EVENTS) { - return; + System.out.println("Incorrect event count. Retrying..."); } - System.out.println("Incorrect event count. Retrying..."); } } }