src/jdk.jfr/share/classes/jdk/jfr/consumer/EventDirectoryStream.java
branchJEP-349-branch
changeset 57628 f5f590eaecf5
parent 57604 838f9a7635b6
child 57638 3b41affae2d2
equal deleted inserted replaced
57627:b38c7a822244 57628:f5f590eaecf5
    33 import java.util.Arrays;
    33 import java.util.Arrays;
    34 import java.util.Comparator;
    34 import java.util.Comparator;
    35 import java.util.Objects;
    35 import java.util.Objects;
    36 import java.util.function.Consumer;
    36 import java.util.function.Consumer;
    37 
    37 
       
    38 import jdk.jfr.internal.SecuritySupport.SafePath;
    38 import jdk.jfr.internal.consumer.RecordingInput;
    39 import jdk.jfr.internal.consumer.RecordingInput;
    39 import jdk.jfr.internal.consumer.RepositoryFiles;
    40 import jdk.jfr.internal.consumer.RepositoryFiles;
    40 
    41 
    41 /**
    42 /**
    42  * Implementation of an {@code EventStream}} that operates against a directory
    43  * Implementation of an {@code EventStream}} that operates against a directory
    56         private RecordedEvent[] sortedList;
    57         private RecordedEvent[] sortedList;
    57         protected long chunkStartNanos;
    58         protected long chunkStartNanos;
    58 
    59 
    59         public DirectoryStream(AccessControlContext acc, Path p) throws IOException {
    60         public DirectoryStream(AccessControlContext acc, Path p) throws IOException {
    60             super(acc);
    61             super(acc);
    61             repositoryFiles = new RepositoryFiles(p);
    62             repositoryFiles = new RepositoryFiles(new SafePath(p));
    62         }
    63         }
    63 
    64 
    64         @Override
    65         @Override
    65         public void process() throws IOException {
    66         public void process() throws IOException {
    66             StreamConfiguration c1 = configuration;
    67             StreamConfiguration c1 = configuration;
    96                         } else {
    97                         } else {
    97                             awaitnewEvent = processUnordered(awaitnewEvent);
    98                             awaitnewEvent = processUnordered(awaitnewEvent);
    98                         }
    99                         }
    99                         runFlushActions();
   100                         runFlushActions();
   100                     }
   101                     }
   101 
   102                     if (isClosed()) {
       
   103                         return;
       
   104                     }
   102                     path = repositoryFiles.nextPath(chunkStartNanos);
   105                     path = repositoryFiles.nextPath(chunkStartNanos);
   103                     if (path == null) {
   106                     if (path == null) {
   104                         return; // stream closed
   107                         return; // stream closed
   105                     }
   108                     }
   106                     chunkStartNanos = repositoryFiles.getTimestamp(path) + 1;
   109                     chunkStartNanos = repositoryFiles.getTimestamp(path) + 1;