提交 9ebf0f88 编写于 作者: A alanb

6866804: (file) Path calls checkPermission insteadof checkXXX (sol)

Reviewed-by: sherman
上级 acd702cf
......@@ -65,9 +65,6 @@ class UnixPath
// array of offsets of elements in path (created lazily)
private volatile int[] offsets;
// file permissions (created lazily)
private volatile FilePermission[] perms;
UnixPath(UnixFileSystem fs, byte[] path) {
this.fs = fs;
this.path = path;
......@@ -768,46 +765,24 @@ class UnixPath
}
}
// create file permissions used for read and write checks
private void checkReadOrWrite(boolean checkRead) {
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return;
if (perms == null) {
synchronized (this) {
if (perms == null) {
FilePermission[] p = new FilePermission[2];
String pathForPermCheck = getPathForPermissionCheck();
p[0] = new FilePermission(pathForPermCheck,
SecurityConstants.FILE_READ_ACTION);
p[1] = new FilePermission(pathForPermCheck,
SecurityConstants.FILE_WRITE_ACTION);
perms = p;
}
}
}
if (checkRead) {
sm.checkPermission(perms[0]);
} else {
sm.checkPermission(perms[1]);
}
}
void checkRead() {
checkReadOrWrite(true);
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkRead(getPathForPermissionCheck());
}
void checkWrite() {
checkReadOrWrite(false);
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkWrite(getPathForPermissionCheck());
}
void checkDelete() {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
// permission not cached
if (sm != null)
sm.checkDelete(getPathForPermissionCheck());
}
}
@Override
public FileStore getFileStore()
......
......@@ -46,6 +46,7 @@ class WindowsFileAttributeViews {
@Override
public WindowsFileAttributes readAttributes() throws IOException {
file.checkRead();
try {
return WindowsFileAttributes.get(file, followLinks);
} catch (WindowsException x) {
......
此差异已折叠。
......@@ -22,7 +22,7 @@
*/
/* @test
* @bug 4313887 6838333 6866804
* @bug 4313887 6838333 6867101
* @summary Unit test for java.nio.file.Path for miscellenous methods not
* covered by other tests
* @library ..
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册