Skip to content

Commit 9827b75

Browse files
committed
8298043: jdk/jfr/api/consumer/recordingstream/TestStop.java failed with "Expected outer stream to have 3 events"
Reviewed-by: mgronlun
1 parent 7d20a60 commit 9827b75

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,21 @@ protected void processRecursionSafe() throws IOException {
166166
processUnordered(disp);
167167
}
168168
currentParser.resetCache();
169-
barrier.check(); // block if recording is being stopped
170169
long endNanos = currentParser.getStartNanos() + currentParser.getChunkDuration();
171170
// same conversion as in RecordingInfo
172-
long endMillis = Instant.ofEpochSecond(0, endNanos).toEpochMilli();
173-
if (barrier.getStreamEnd() <= endMillis) {
174-
return;
175-
}
176171
if (endNanos > filterEnd) {
177172
return;
178173
}
179174
}
180-
if (isLastChunk()) {
175+
long endNanos = currentParser.getStartNanos() + currentParser.getChunkDuration();
176+
long endMillis = Instant.ofEpochSecond(0, endNanos).toEpochMilli();
177+
178+
barrier.check(); // block if recording is being stopped
179+
if (barrier.getStreamEnd() <= endMillis) {
180+
return;
181+
}
182+
183+
if (!barrier.hasStreamEnd() && isLastChunk()) {
181184
// Recording was stopped/closed externally, and no more data to process.
182185
return;
183186
}

src/jdk.jfr/share/classes/jdk/jfr/internal/management/StreamBarrier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public synchronized long getStreamEnd() {
6262
return end;
6363
}
6464

65+
public synchronized boolean hasStreamEnd() {
66+
return end != Long.MAX_VALUE;
67+
}
68+
6569
public synchronized void activate() {
6670
activated = true;
6771
}

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,6 @@ jdk/jfr/startupargs/TestStartDuration.java 8214685 windows-
749749
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
750750
jdk/jfr/api/consumer/recordingstream/TestOnEvent.java 8255404 linux-x64
751751
jdk/jfr/api/consumer/TestRecordingFileWrite.java 8287699 generic-all
752-
jdk/jfr/api/consumer/recordingstream/TestStop.java 8298043 generic-all
753752

754753
############################################################################
755754

test/jdk/jdk/jfr/api/consumer/recordingstream/TestStop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private static void testNestedStop() throws Exception {
149149
if (dumpOuter.size() != 3) {
150150
throw new AssertionError("Expected outer dump to have 3 events");
151151
}
152-
if (outerCount.get() == 3) {
152+
if (outerCount.get() != 3) {
153153
throw new AssertionError("Expected outer stream to have 3 events");
154154
}
155155
if (dumpInner.size() != 1) {

test/jdk/jdk/jfr/jmx/streaming/TestStop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static void testNestedStop() throws Exception {
158158
if (dumpOuter.size() != 3) {
159159
throw new AssertionError("Expected outer dump to have 3 events");
160160
}
161-
if (outerCount.get() == 3) {
161+
if (outerCount.get() != 3) {
162162
throw new AssertionError("Expected outer stream to have 3 events");
163163
}
164164
if (dumpInner.size() != 1) {

0 commit comments

Comments
 (0)