* Make FsBlobContainer Listing Resilient to Concurrent Modifications If we list out files in a folder via the lazily computed directory stream, we have to deal with concurrent deletes when reading the file attributes since we don't have a lock on the directory in any way. Closes #37581
This commit is contained in:
parent
57f57227ac
commit
2886d4c6dd
|
@ -97,7 +97,13 @@ public class FsBlobContainer extends AbstractBlobContainer {
|
|||
blobNamePrefix = blobNamePrefix == null ? "" : blobNamePrefix;
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path, blobNamePrefix + "*")) {
|
||||
for (Path file : stream) {
|
||||
final BasicFileAttributes attrs = Files.readAttributes(file, BasicFileAttributes.class);
|
||||
final BasicFileAttributes attrs;
|
||||
try {
|
||||
attrs = Files.readAttributes(file, BasicFileAttributes.class);
|
||||
} catch (FileNotFoundException | NoSuchFileException e) {
|
||||
// The file was concurrently deleted between listing files and trying to get its attributes so we skip it here
|
||||
continue;
|
||||
}
|
||||
if (attrs.isRegularFile()) {
|
||||
builder.put(file.getFileName().toString(), new PlainBlobMetaData(file.getFileName().toString(), attrs.size()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue