8244149: jdk/jfr/api/consumer/recordingstream/TestOnEvent.java times out

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2020-05-04 23:16:44 +02:00
parent df182ea6e0
commit 600319b68a

View File

@ -26,6 +26,7 @@
package jdk.jfr.api.consumer.recordingstream;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import jdk.jfr.Event;
import jdk.jfr.Name;
@ -96,7 +97,7 @@ public class TestOnEvent {
System.out.println("testTwoEventWithSameName" + e);
eventA.countDown();
});
r.startAsync();
start(r);
EventA a1 = new EventA();
a1.commit();
EventAlsoA a2 = new EventAlsoA();
@ -124,7 +125,7 @@ public class TestOnEvent {
}
});
r.startAsync();
start(r);
EventA a = new EventA();
a.commit();
EventC c = new EventC();
@ -142,7 +143,7 @@ public class TestOnEvent {
r.onEvent(e -> {
event.countDown();
});
r.startAsync();
start(r);
EventA a = new EventA();
a.commit();
event.await();
@ -172,6 +173,18 @@ public class TestOnEvent {
}
}
// Starts recording stream and ensures stream
// is receiving events before method returns.
private static void start(RecordingStream rs) throws InterruptedException {
CountDownLatch started = new CountDownLatch(1);
rs.onFlush(() -> {
if (started.getCount() > 0) {
started.countDown();
}
});
rs.startAsync();
started.await();
}
private static void log(String msg) {
System.out.println(msg);