--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSet.java Thu May 30 23:12:44 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSet.java Fri May 31 20:44:28 2019 +0200
@@ -138,14 +138,14 @@
dirtyFilter = true;
}
- public RecordedEvent[] readEvents(int index) throws Exception {
+ public RecordedEvent[] readEvents(int index) throws IOException {
while (!closed) {
RecordedEvent[] events = (RecordedEvent[]) segments[index];
if (events != null) {
return events;
}
- if (lock.tryLock(250, TimeUnit.MILLISECONDS)) {
+ if (await()) {
try {
addSegment(index);
} finally {
@@ -156,6 +156,14 @@
return null;
}
+ private boolean await() {
+ try {
+ return lock.tryLock(250, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ return false;
+ }
+ }
+
// held with lock
private void addSegment(int index) throws IOException {
if (chunkParser == null) {