Skip to content

Commit

Permalink
8244149: jdk/jfr/api/consumer/recordingstream/TestOnEvent.java times out
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed May 4, 2020
1 parent df182ea commit 600319b
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -124,7 +125,7 @@ private static void testNamedEvent() throws Exception {
}
});

r.startAsync();
start(r);
EventA a = new EventA();
a.commit();
EventC c = new EventC();
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 600319b

Please sign in to comment.