ADDITIONAL SYSTEM INFORMATION :
macOS 10.13.6 (17G5019), but reliably reproduceable on any Mac or Linux system.
openjdk version "11.0.2" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Calling BasicFileAttributeView.setTimes fails for any symlink:
Exception in thread "main" java.nio.file.FileSystemException: /tmp/symlink: Too many levels of symbolic links or unable to access attributes of symbolic link
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:96)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.setTimes(UnixFileAttributeViews.java:85)
This issue is closely related to https://bugs.openjdk.java.net/browse/JDK-8139133, but with the difference that for symbolic links sun.nio.fs.UnixPath#openForAttributeAccess doesn't throw an ENXIO error but an ELOOP error. Therefore the fix forJDK-8139133 can be extended to also fix this issue.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a symlink (target doesn't need to exist):
ln -s foo /tmp/symlink
Then run the Java test case program attached to this issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Last Modified Date of /tmp/symlink is set to 2001-09-09
ACTUAL -
java.nio.file.FileSystemException: /tmp/symlink: Too many levels of symbolic links or unable to access attributes of symbolic link
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileTime;
public class SymlinkTest {
public static void main(String args[]) throws IOException {
Path link = Paths.get("/tmp/symlink");
BasicFileAttributeView view = Files.getFileAttributeView(link, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
view.setTimes(FileTime.fromMillis(1000000000000l), null, null);
}
}
---------- END SOURCE ----------
FREQUENCY : always
macOS 10.13.6 (17G5019), but reliably reproduceable on any Mac or Linux system.
openjdk version "11.0.2" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.2+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+7, mixed mode)
A DESCRIPTION OF THE PROBLEM :
Calling BasicFileAttributeView.setTimes fails for any symlink:
Exception in thread "main" java.nio.file.FileSystemException: /tmp/symlink: Too many levels of symbolic links or unable to access attributes of symbolic link
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:96)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.setTimes(UnixFileAttributeViews.java:85)
This issue is closely related to https://bugs.openjdk.java.net/browse/JDK-8139133, but with the difference that for symbolic links sun.nio.fs.UnixPath#openForAttributeAccess doesn't throw an ENXIO error but an ELOOP error. Therefore the fix for
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a symlink (target doesn't need to exist):
ln -s foo /tmp/symlink
Then run the Java test case program attached to this issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Last Modified Date of /tmp/symlink is set to 2001-09-09
ACTUAL -
java.nio.file.FileSystemException: /tmp/symlink: Too many levels of symbolic links or unable to access attributes of symbolic link
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileTime;
public class SymlinkTest {
public static void main(String args[]) throws IOException {
Path link = Paths.get("/tmp/symlink");
BasicFileAttributeView view = Files.getFileAttributeView(link, BasicFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
view.setTimes(FileTime.fromMillis(1000000000000l), null, null);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- links to