提交 235b51f4 编写于 作者: D Denghui Dong 提交者: D-D-H

[Backport] 8233870: JFR TestSetEndTime.java times out - onClose() is never called

Summary:

Test Plan: jdk/jfr

Reviewed-by: yuleil

Issue: https://github.com/alibaba/dragonwell8/issues/112
上级 64e12c67
......@@ -292,4 +292,8 @@ public final class ChunkHeader {
static long headerSize() {
return HEADER_SIZE;
}
public long getLastNanos() {
return getStartNanos() + getDurationNanos();
}
}
......@@ -202,7 +202,7 @@ public final class ChunkParser {
long lastValid = absoluteChunkEnd;
long metadataPoistion = chunkHeader.getMetataPosition();
long contantPosition = chunkHeader.getConstantPoolPosition();
chunkFinished = awaitUpdatedHeader(absoluteChunkEnd);
chunkFinished = awaitUpdatedHeader(absoluteChunkEnd, configuration.filterEnd);
if (chunkFinished) {
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "At chunk end");
return null;
......@@ -279,11 +279,14 @@ public final class ChunkParser {
}
}
private boolean awaitUpdatedHeader(long absoluteChunkEnd) throws IOException {
private boolean awaitUpdatedHeader(long absoluteChunkEnd, long filterEnd) throws IOException {
if (Logger.shouldLog(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO)) {
Logger.log(LogTag.JFR_SYSTEM_PARSER, LogLevel.INFO, "Waiting for more data (streaming). Read so far: " + chunkHeader.getChunkSize() + " bytes");
}
while (true) {
if (chunkHeader.getLastNanos() > filterEnd) {
return true;
}
chunkHeader.refresh();
if (absoluteChunkEnd != chunkHeader.getEnd()) {
return false;
......
......@@ -62,6 +62,14 @@ public final class TestSetEndTime {
public static void main(String... args) throws Exception {
testEventStream();
testRecordingStream();
testEmptyStream();
}
private static void testEmptyStream() {
try (RecordingStream rs = new RecordingStream()) {
rs.setEndTime(Instant.now().plusMillis(1100));
rs.start();
}
}
private static void testRecordingStream() throws Exception {
......@@ -88,10 +96,10 @@ public final class TestSetEndTime {
}
closed.await();
System.out.println("Found events: " + count.get());
if (count.get() < 50) {
if (count.get() > 0 && count.get() < 50) {
return;
}
System.out.println("Found 50 events. Retrying");
System.out.println("Retrying");
System.out.println();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册