Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8162388

(fc) FileChannel cannot be opened for writing for a file on a gvfs mounted webdav share

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_65"
      Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      An attempt to open a FileChannel or AsynchronousFileChannel e.g. using FileChannel.open(path, StandardOpenOption.WRITE) fails if path points to a file on a gvfs mounted WebDav share.

      When using the terminal to inspect the share ls -l shows that the files are writable by the user running the java program. In addition using a FileOutputStream to write data to the file is possible.

      When mounting the same WebDav share using mount -t davfs [...] channels can be opened.

      When doing FileChannel.open(path, StandardOpenOption.READ) this works so seem to be releated to the WRITE option.

      I am note sure if this applies to all gvfs mounts or only WebDav shares. I confirmed this for a WebDav share.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1 Start a webdav server which may afterwards be reachable e.g. at http://localhost:42232/a
      2 Use "gvfs-mount dav:localhost:42232/a" to mount the drive.
      3 Create a file "test" in this share using e.g. a text editor.
      4 Create a path to the file (gvfs mounted to /run/user/1000/gvfs/dav:host=localhost,port=42232,ssl=false,prefix=%2Fa in my example)
      5 Use this path to create a file channel with the WRITE open option specified

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Because writing is in general possible, e.g. using FileOutputStream, I would expect it to create a writable FileChannel as an alternativ an UnsupportedOperationException as specified in the javadoc of open could be thrown.
      ACTUAL -
      A FileSystemException (not UnsupportedOperationException) with message "Operation not supported" is thrown.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.nio.file.FileSystemException: /run/user/1000/gvfs/dav:host=localhost,port=42232,ssl=false,prefix=%2Fa/test: Operation not supported
      at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91)
      at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      at sun.nio.fs.UnixFileSystemProvider.newAsynchronousFileChannel(UnixFileSystemProvider.java:196)
      at java.nio.channels.AsynchronousFileChannel.open(AsynchronousFileChannel.java:248)
      at java.nio.channels.AsynchronousFileChannel.open(AsynchronousFileChannel.java:301)
      [...]



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      private final String root = "/run/user/1000/gvfs/dav:host=localhost,port=42232,ssl=false,prefix=%2Fa";
      private final Path test = Paths.get(root + "/test");

      @Test
      public void testCreateChannelForWriting() throws IOException {
      try (FileChannel channel = FileChannel.open(test, StandardOpenOption.WRITE)) {

      }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Mount the filesystem using mount -t davfs [...] instead of gvfs. This is possible in some cases but not always an option because the mount process used by third party software can not always be influenced.

        1. JI9041749.java
          0.5 kB
        2. log.txt
          10 kB

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: