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

(fc) FileChannel.force fails on WebDAV file systems (macOS)

    XMLWordPrintable

Details

    • b18
    • x86
    • os_x

    Description

      ADDITIONAL SYSTEM INFORMATION :
      macOS 10.14.6, Tested with Oracle JDK 8u202, 8u221 and 13

      A DESCRIPTION OF THE PROBLEM :
      Beginning with Java 9 it is no longer possible to call force() on a FileChannel pointing to a file on a mounted WebDAV drive (similar reports for CIFS drives on Linux that I can not confirm).

      REGRESSION : Last worked in version 8u221

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Mount a WebDAV-Drive (in Finder press ⌘K). For Testing you can use a URL obtained from the upper right corner of webdavserver.com
      2. Run attached test class, provide an absolute path to a any existing or nonexisting file inside the mounted drive as arg[0]

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception
      ACTUAL -
      java.io.IOException: Invalid argument
      at java.base/sun.nio.ch.FileDispatcherImpl.force0(Native Method)
      at java.base/sun.nio.ch.FileDispatcherImpl.force(FileDispatcherImpl.java:82)
      at java.base/sun.nio.ch.FileChannelImpl.force(FileChannelImpl.java:461)

      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.nio.channels.FileChannel;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.nio.file.StandardOpenOption;

      public class ChannelForceTest {

      public static void main(String args[]) {
      if (args.length != 1) {
      System.out.println("Run with arg[0] being an absolute path to a webdav-mounted directory");
      System.exit(1);
      }

      Path p = Paths.get(args[0]);
      try (FileChannel ch = FileChannel.open(p, StandardOpenOption.WRITE, StandardOpenOption.CREATE)) {
      ch.force(true); // fails
      System.out.println("No exception under JDK 8");
      } catch (IOException e) {
      System.out.println("Exception under JDK 9+");
      e.printStackTrace();
      }
      }

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

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: