trino
                                
                                
                                
                                    trino copied to clipboard
                            
                            
                            
                        Suppress NoSuchFileException in LocalFileIterator
Description
Files.walk method may throw an exception during the iteration. https://bugs.openjdk.org/browse/JDK-8039910 Fixes #20520
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
Please get @electrum to review this before merging. The exact behavior of exceptions from the file system implementations is required to be consistent, and I'd like david to make sure this is following the expected behavior.
So I believe that the first commit is correct and the second commit is not needed.
@electrum Both commits are required to fix the concurrent issue. LocalFileIterator#next calls Files.size(path). It throws NoSuchFileException if the file is deleted concurrently.
Thanks for explaining. We should change LocalFileIterator to ignore those exceptions by not returning the file entry. Listing files is not atomic, so this is an expected race condition that we need to handle.
We should change LocalFileIterator to ignore those exceptions by not returning the file entry.
@ebyhr did you consider making use of a simplified version of java.nio.file.Files#walkFileTree(java.nio.file.Path, java.util.Set<java.nio.file.FileVisitOption>, int, java.nio.file.FileVisitor<? super java.nio.file.Path>) (what Files.walkFileTree uses in the background) and create the FileEntry instances on the fly in the LocalFileIterator?