diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java index 319d1d72598..b8daf551c69 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -156,6 +156,7 @@ public abstract class UnixFileSystemProvider { if (type == BasicFileAttributes.class && Util.followLinks(options)) { UnixPath file = UnixPath.toUnixPath(path); + file.checkRead(); try { @SuppressWarnings("unchecked") A attrs = (A) UnixFileAttributes.getIfExists(file); diff --git a/test/jdk/java/nio/file/Files/CheckPermissions.java b/test/jdk/java/nio/file/Files/CheckPermissions.java index 5a50596d847..fd09b71da48 100644 --- a/test/jdk/java/nio/file/Files/CheckPermissions.java +++ b/test/jdk/java/nio/file/Files/CheckPermissions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ */ /* @test - * @bug 6866804 7006126 8028270 8065109 + * @bug 6866804 7006126 8028270 8065109 8289984 * @summary Unit test for java.nio.file.Files * @library .. * @build CheckPermissions @@ -219,6 +219,14 @@ public class CheckPermissions { exists(file); assertCheckRead(file); + prepare(); + isRegularFile(file); + assertCheckRead(file); + + prepare(); + isDirectory(file); + assertCheckRead(file); + prepare(); isReadable(file); assertCheckRead(file);