8323196: jdk/jfr/api/consumer/filestream/TestOrdered.java failed with "Events are not ordered! Reuse = false"
Reviewed-by: mgronlun
This commit is contained in:
parent
6a5cb0b2c4
commit
bdd96604ae
@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import jdk.jfr.Event;
|
||||
@ -143,8 +144,8 @@ public class TestOrdered {
|
||||
}
|
||||
|
||||
private static Path makeUnorderedRecording() throws Exception {
|
||||
while (true) {
|
||||
CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT + 1);
|
||||
|
||||
try (Recording r = new Recording()) {
|
||||
r.start();
|
||||
List<Emitter> emitters = new ArrayList<>();
|
||||
@ -164,7 +165,22 @@ public class TestOrdered {
|
||||
r.stop();
|
||||
Path p = Utils.createTempFile("recording", ".jfr");
|
||||
r.dump(p);
|
||||
// Order is only guaranteed within a segment.
|
||||
int segments = countSegments(p);
|
||||
if (segments < 2) {
|
||||
return p;
|
||||
}
|
||||
System.out.println("File contains more than one segment (" + segments + "). Retrying.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int countSegments(Path file) throws Exception {
|
||||
AtomicInteger segments = new AtomicInteger();
|
||||
try (EventStream es = EventStream.openFile(file)) {
|
||||
es.onFlush(segments::incrementAndGet);
|
||||
es.start();
|
||||
return segments.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user