changeset 11982:eb7d3e11a8cb

8080629: (fs) Re-enable ability to fsync() on directories even though read()s on those directories may fail. Summary: Revert fix applied to resolve JDK-8066915. Reviewed-by: alanb
author bpb
date Tue, 19 May 2015 07:12:10 -0700
parents a5f2abfa5a15
children f87c00a6287f
files src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java test/java/nio/file/Files/SBC.java
diffstat 2 files changed, 1 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java	Tue May 19 16:04:14 2015 +0400
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixChannelFactory.java	Tue May 19 07:12:10 2015 -0700
@@ -270,22 +270,6 @@
             throw x;
         }
 
-        // fail if the file is a directory
-        if (flags.read) {
-            UnixException exc = null;
-            try {
-                if (UnixFileAttributes.get(fd).isDirectory()) {
-                    exc = new UnixException(EISDIR);
-                }
-            } catch (UnixException x) {
-                exc = x;
-            }
-            if (exc != null) {
-                close(fd);
-                throw exc;
-            }
-        }
-
         // unlink file immediately if delete on close. The spec is clear that
         // an implementation cannot guarantee to unlink the correct file when
         // replaced by an attacker after it is opened.
--- a/test/java/nio/file/Files/SBC.java	Tue May 19 16:04:14 2015 +0400
+++ b/test/java/nio/file/Files/SBC.java	Tue May 19 07:12:10 2015 -0700
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 8066915
+ * @bug 4313887
  * @summary Unit test for java.nio.file.Files.newByteChannel
  * @library ..
  */
@@ -59,7 +59,6 @@
                 dosSharingOptionTests(dir);
 
             // misc. tests
-            directoryOpenTests(dir);
             badCombinations(dir);
             unsupportedOptions(dir);
             nullTests(dir);
@@ -279,21 +278,6 @@
         }
     }
 
-    // test opening a directory for read or write
-    static void directoryOpenTests(Path dir) throws Exception {
-        try (SeekableByteChannel sbc = Files.newByteChannel(dir, READ)) {
-            throw new RuntimeException("Opened directory for read");
-        } catch (IOException expected) { }
-
-        try (SeekableByteChannel sbc = Files.newByteChannel(dir, WRITE)) {
-            throw new RuntimeException("Opened directory for write");
-        } catch (IOException expected) { }
-
-        try (SeekableByteChannel sbc = Files.newByteChannel(dir, APPEND)) {
-            throw new RuntimeException("Opened directory for append ");
-        } catch (IOException expected) { }
-    }
-
     // Windows specific options for the use by applications that really want
     // to use legacy DOS sharing options
     static void dosSharingOptionTests(Path dir) throws Exception {