Skip to content

Commit 57df0db

Browse files
committed
8270873: JFR: Catch DirectoryIteratorException when scanning for .jfr files
Reviewed-by: mgronlun
1 parent 111d5e1 commit 57df0db

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package jdk.jfr.internal.consumer;
2727

2828
import java.io.IOException;
29+
import java.nio.file.DirectoryIteratorException;
2930
import java.nio.file.DirectoryStream;
3031
import java.nio.file.Path;
3132
import java.nio.file.attribute.FileTime;
@@ -100,12 +101,11 @@ private boolean updatePaths(boolean wait) {
100101
if (updatePaths()) {
101102
break;
102103
}
103-
} catch (IOException e) {
104-
Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.DEBUG, "IOException during repository file scan " + e.getMessage());
104+
} catch (IOException | DirectoryIteratorException e) {
105+
Logger.log(LogTag.JFR_SYSTEM_STREAMING, LogLevel.DEBUG, "Exception during repository file scan " + e.getMessage());
105106
// This can happen if a chunk is being removed
106107
// between the file was discovered and an instance
107-
// was accessed, or if new file has been written yet
108-
// Just ignore, and retry later.
108+
// was accessed. Just ignore, and retry later.
109109
}
110110
if (wait) {
111111
nap();
@@ -131,7 +131,7 @@ public Path nextPath(long startTimeNanos, boolean wait) {
131131
// Update paths
132132
try {
133133
updatePaths();
134-
} catch (IOException e) {
134+
} catch (IOException | DirectoryIteratorException e) {
135135
// ignore
136136
}
137137
// try to get the next file
@@ -167,7 +167,7 @@ private void nap() {
167167
}
168168
}
169169

170-
private boolean updatePaths() throws IOException {
170+
private boolean updatePaths() throws IOException, DirectoryIteratorException {
171171
boolean foundNew = false;
172172
Path repoPath = repository;
173173

@@ -254,7 +254,7 @@ private Path findSubDirectory(Path repoPath) {
254254
}
255255
}
256256
}
257-
} catch (IOException e) {
257+
} catch (IOException | DirectoryIteratorException e) {
258258
// Ignore
259259
}
260260
return latestPath;

0 commit comments

Comments
 (0)