From f39f848c99e4313e4dbd860744a5b4b864e060bf Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Mon, 17 Aug 2020 14:23:29 +0200 Subject: [PATCH] Document that setLastModified sets time of symlink target Due to Java bug JDK-8220793 [1] Java cannot set timestamps of a symlink but only of the symlink target. This bug was fixed in Java 13. Since we don't have a use case to set the timestamp of the symlink itself simply document the current behavior of setLastModified methods. [1] https://bugs.openjdk.java.net/browse/JDK-8220793 Change-Id: Ibc28c1702a1b9845602bd257606fbd44803a43fb Signed-off-by: Matthias Sohn --- org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java | 10 ++++++---- .../src/org/eclipse/jgit/util/FileUtils.java | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index bf7b75369..d8cab358e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -1080,8 +1080,9 @@ public Instant lastModifiedInstant(File f) { } /** - * Set the last modified time of a file system object. If the OS/JRE support - * symbolic links, the link is modified, not the target, + * Set the last modified time of a file system object. + *

+ * For symlinks it sets the modified time of the link target. * * @param f * a {@link java.io.File} object. @@ -1097,8 +1098,9 @@ public void setLastModified(File f, long time) throws IOException { } /** - * Set the last modified time of a file system object. If the OS/JRE support - * symbolic links, the link is modified, not the target, + * Set the last modified time of a file system object. + *

+ * For symlinks it sets the modified time of the link target. * * @param p * a {@link Path} object. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java index c43956e53..aa39a4464 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java @@ -710,6 +710,8 @@ static BasicFileAttributes fileAttributes(File file) throws IOException { } /** + * Set the last modified time of a file system object. + * * @param file * @param time * @throws IOException @@ -720,6 +722,8 @@ static void setLastModified(File file, long time) throws IOException { } /** + * Set the last modified time of a file system object. + * * @param path * @param time * @throws IOException