# HG changeset patch # User alanb # Date 1361965481 0 # Node ID 607d2fb48f478c8a98220262d418d778efbf3717 # Parent 75811cab01809332100f30dd4e0c5f8852ade518 8004288: (fs) Files.probeContentType problems Reviewed-by: ahgross, sherman diff -r 75811cab0180 -r 607d2fb48f47 jdk/src/share/classes/java/nio/file/Files.java --- a/jdk/src/share/classes/java/nio/file/Files.java Wed Feb 27 12:10:59 2013 +0400 +++ b/jdk/src/share/classes/java/nio/file/Files.java Wed Feb 27 11:44:41 2013 +0000 @@ -1485,10 +1485,19 @@ // lazy loading of default and installed file type detectors private static class FileTypeDetectors{ static final FileTypeDetector defaultFileTypeDetector = - sun.nio.fs.DefaultFileTypeDetector.create(); + createDefaultFileTypeDetector(); static final List installeDetectors = loadInstalledDetectors(); + // creates the default file type detector + private static FileTypeDetector createDefaultFileTypeDetector() { + return AccessController + .doPrivileged(new PrivilegedAction() { + @Override public FileTypeDetector run() { + return sun.nio.fs.DefaultFileTypeDetector.create(); + }}); + } + // loads all installed file type detectors private static List loadInstalledDetectors() { return AccessController diff -r 75811cab0180 -r 607d2fb48f47 jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java --- a/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Wed Feb 27 12:10:59 2013 +0400 +++ b/jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java Wed Feb 27 11:44:41 2013 +0000 @@ -67,6 +67,8 @@ NativeBuffer buffer = NativeBuffers.asNativeBuffer(path.getByteArrayForSysCalls()); try { if (gioAvailable) { + // GIO may access file so need permission check + path.checkRead(); byte[] type = probeUsingGio(buffer.address()); return (type == null) ? null : new String(type); } else { @@ -76,7 +78,6 @@ String s = new String(type); return s.equals(GNOME_VFS_MIME_TYPE_UNKNOWN) ? null : s; } - } finally { buffer.release(); }