Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion test/jdk/jdk/jfr/tool/TestPrintContextual.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -264,7 +265,8 @@ private static void testDeepContext() throws Exception {
}
}

private static void span(int depth) {
private static void span(int depth) throws InterruptedException {
awaitUniqueTimestamp();
SpanEvent span = new SpanEvent();
span.name = "span";
span.spanId = depth;
Expand All @@ -277,6 +279,13 @@ private static void span(int depth) {
span.commit();
}

private static void awaitUniqueTimestamp() throws InterruptedException {
Instant timestamp = Instant.now();
while (timestamp.equals(Instant.now())) {
Thread.sleep(1);
}
}

// Tests that context values are only inhjected into events in the same thread.
private static void testThreadedContext() throws Exception {
try (Recording r = new Recording()) {
Expand Down