Skip to content

Commit 2376a9e

Browse files
committed
8365630: jdk/jfr/tool/TestPrintContextual.java fails with wrong spanId
Reviewed-by: shade
1 parent 0f406c4 commit 2376a9e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/jdk/jdk/jfr/tool/TestPrintContextual.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.nio.file.Files;
2727
import java.nio.file.Path;
28+
import java.time.Instant;
2829
import java.util.AbstractMap;
2930
import java.util.ArrayList;
3031
import java.util.List;
@@ -264,7 +265,8 @@ private static void testDeepContext() throws Exception {
264265
}
265266
}
266267

267-
private static void span(int depth) {
268+
private static void span(int depth) throws InterruptedException {
269+
awaitUniqueTimestamp();
268270
SpanEvent span = new SpanEvent();
269271
span.name = "span";
270272
span.spanId = depth;
@@ -277,6 +279,13 @@ private static void span(int depth) {
277279
span.commit();
278280
}
279281

282+
private static void awaitUniqueTimestamp() throws InterruptedException {
283+
Instant timestamp = Instant.now();
284+
while (timestamp.equals(Instant.now())) {
285+
Thread.sleep(1);
286+
}
287+
}
288+
280289
// Tests that context values are only inhjected into events in the same thread.
281290
private static void testThreadedContext() throws Exception {
282291
try (Recording r = new Recording()) {

0 commit comments

Comments
 (0)