diff options
author | Martin Fick <mfick@nvidia.com> | 2024-12-05 15:53:01 -0800 |
---|---|---|
committer | Martin Fick <mfick@nvidia.com> | 2024-12-05 17:22:40 -0800 |
commit | 7fedd15c82eda8c8ff694b6e809e83bd64a5ab33 (patch) | |
tree | 7e26d10106ce99626e385337da8689e28f234ad7 | |
parent | 8c4a150164eee728bc6d290f9da2baa1808c1e75 (diff) | |
download | jgit-7fedd15c82eda8c8ff694b6e809e83bd64a5ab33.tar.gz jgit-7fedd15c82eda8c8ff694b6e809e83bd64a5ab33.zip |
FileSnapshot: silence "Stale file handle" exceptions
Sometimes a FileSystemException with "Stale file handle" can be thrown
while creating a FileSnapshot, likely because the file or directory was
deleted. Since NoSuchFileExceptions are already silenced, and the
FileSnapshot already handles all IOExceptions, there is likely no value
in seeing this info in the logs, treat these situation the same and
silence them also.
Change-Id: I922f4edf2d332cd704e60276f41a76df242f281c
Signed-off-by: Martin Fick <mfick@nvidia.com>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java index d34baf358c..d752e315db 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileSnapshot.java @@ -28,6 +28,7 @@ import java.util.Objects; import java.util.concurrent.TimeUnit; import org.eclipse.jgit.annotations.NonNull; +import org.eclipse.jgit.util.FileUtils; import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.FS.FileStoreAttributes; import org.slf4j.Logger; @@ -580,11 +581,18 @@ public class FileSnapshot { private static BasicFileAttributes getFileAttributes(File path) throws NoSuchElementException { try { - return FS.DETECTED.fileAttributes(path); + try { + return FS.DETECTED.fileAttributes(path); + } catch (IOException e) { + if (!FileUtils.isStaleFileHandle(e)) { + throw e; + } + } } catch (NoSuchFileException e) { } catch (FileSystemException e) { - if (!e.getMessage().endsWith("Not a directory")) { - LOG.error(e.getMessage(), e); + String msg = e.getMessage(); + if (!msg.endsWith("Not a directory")) { + LOG.error(msg, e); } } catch (IOException e) { LOG.error(e.getMessage(), e); |