src/jdk.jfr/share/classes/jdk/jfr/consumer/EventSet.java
branchJEP-349-branch
changeset 57385 7d9d4f629f6e
parent 57376 8e8a06a3059c
--- 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) {