-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Make FsBlobContainer Listing Resilient to Concurrent Modifications #49142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,13 @@ public Map<String, BlobMetaData> listBlobsByPrefix(String blobNamePrefix) throws | |
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()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps easier as the two suggestions above is to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't help us I think? We still want the file size two lines below where we'd have to make another call to the FS that we'd have to guard against "file not found". |
||
builder.put(file.getFileName().toString(), new PlainBlobMetaData(file.getFileName().toString(), attrs.size())); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment here saying why it's ok to ignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)