Skip to content
Permalink
Browse files

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

Reviewed-by: mgronlun
  • Loading branch information
Erik Gahlin
Erik Gahlin committed May 4, 2020
1 parent df182ea commit 600319b68a62083e3377224ce27e1e2b00ebfd99
Showing with 16 additions and 3 deletions.
  1. +16 −3 test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java
@@ -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 @@ private static void testTwoEventWithSameName() throws Exception {
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 @@ private static void testNamedEvent() throws Exception {
}
});

r.startAsync();
start(r);
EventA a = new EventA();
a.commit();
EventC c = new EventC();
@@ -142,7 +143,7 @@ private static void testOnEvent() throws Exception {
r.onEvent(e -> {
event.countDown();
});
r.startAsync();
start(r);
EventA a = new EventA();
a.commit();
event.await();
@@ -172,6 +173,18 @@ private static void testOnEventAfterStart() {
}
}

// 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);

0 comments on commit 600319b

Please sign in to comment.