8365630: jdk/jfr/tool/TestPrintContextual.java fails with wrong spanId

Reviewed-by: shade
This commit is contained in:
Erik Gahlin 2025-10-06 17:30:42 +00:00
parent 0f406c420e
commit 2376a9e972

View File

@ -25,6 +25,7 @@ package jdk.jfr.tool;
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;
@ -264,7 +265,8 @@ public class TestPrintContextual {
}
}
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;
@ -277,6 +279,13 @@ public class TestPrintContextual {
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()) {