Browse Source

FileUtils#lastModifiedInstant should not log error if path doesn't exist

Change-Id: Id8447735beb24becb41612d3d29d5351f8273d22
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Matthias Sohn 5 years ago
parent
commit
31356f5d18
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java

8
org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java

@ -55,6 +55,7 @@ import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
@ -677,9 +678,14 @@ public class FileUtils {
try {
return Files.getLastModifiedTime(path, LinkOption.NOFOLLOW_LINKS)
.toInstant();
} catch (NoSuchFileException e) {
LOG.debug(
"Cannot read lastModifiedInstant since path {} does not exist", //$NON-NLS-1$
path);
return Instant.EPOCH;
} catch (IOException e) {
LOG.error(MessageFormat
.format(JGitText.get().readLastModifiedFailed, path));
.format(JGitText.get().readLastModifiedFailed, path), e);
return Instant.ofEpochMilli(path.toFile().lastModified());
}
}

Loading…
Cancel
Save