8289984: Files:isDirectory and isRegularFile methods not throwing SecurityException

Reviewed-by: iris, alanb
This commit is contained in:
Lance Andersen 2022-07-08 18:56:04 +00:00
parent 1877533f75
commit 6aaf141f61
2 changed files with 11 additions and 2 deletions
src/java.base/unix/classes/sun/nio/fs
test/jdk/java/nio/file/Files

@ -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);

@ -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();
isDirectory(file);
assertCheckRead(file);
prepare();
isRegularFile(file);
assertCheckRead(file);
prepare();
isReadable(file);
assertCheckRead(file);