8335632: jdk/jfr/api/consumer/streaming/TestJVMExit.java failed with "Process [...] is no longer alive"

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2024-07-05 17:07:22 +00:00
parent 7efe16038e
commit b83766e590

View File

@ -34,12 +34,29 @@ import jdk.jfr.consumer.EventStream;
* @requires vm.hasJFR
* @library /test/lib /test/jdk
* @modules jdk.jfr jdk.attach java.base/jdk.internal.misc
* @build jdk.jfr.api.consumer.streaming.TestProcess
*
* @run main/othervm -Dsun.tools.attach.attachTimeout=100000 jdk.jfr.api.consumer.streaming.TestJVMExit
*/
public class TestJVMExit {
public static void main(String... args) throws Exception {
while (true) {
try {
testExit();
return;
} catch (RuntimeException e) {
String message = String.valueOf(e.getMessage());
// If the test application crashes during startup, retry.
if (!message.contains("is no longer alive")) {
throw e;
}
System.out.println("Application not alive when trying to get repository. Retrying.");
}
}
}
private static void testExit() throws Exception {
try (TestProcess process = new TestProcess("exit-application")) {
AtomicInteger eventCounter = new AtomicInteger();
try (EventStream es = EventStream.openRepository(process.getRepository())) {