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

FileSystemProvider.checkAccess(path, AccessMode.Write), improper behavior

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 7
    • core-libs
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6002]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      non-administrative account

      A DESCRIPTION OF THE PROBLEM :
      Using FileSystemProvider.checkAccout (path, AccessMode.WRITE) throws an AccessDeniedException for 'path' if you work on a non-administrative account - but you can effectivly write the file denoted by 'path'.

      As other code, especially Files.isWritable(path) is based on this, also this code is affected. The nice ZipFileSystem provided with Java 7 will open any zip-Files only in read-only mode, if you work with a non-administrative account.

      If using an administrative account everything will be perfect.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      static void testWriteAndWriteAccess() {
        
          String filename = "test.txt";
          Path path = Paths.get(filename);
          
          try {
            Files.write(path, Arrays.asList("first-line", "second-line"),
              StandardCharsets.UTF_8, StandardOpenOption.CREATE);
          
            System.out.println("writable = " + Files.isWritable(path));
            path.getFileSystem().provider().checkAccess(path, AccessMode.WRITE); }
            
          catch (Exception e) {
            e.printStackTrace(); }
            
        }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      - create / update the file 'test.txt' with the two lines 'first-lin", "second-line"
      - isWritable() returns true
      - no exception
      ACTUAL -
      (on non-administrative account)
      - create / update the file 'test.txt' with the two lines 'first-lin", "second-line"
      - isWritable() returns false
      - java.nio.file.AccessDeniedException: test.txt: Effective permissions does not allow requested access

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.nio.file.AccessDeniedException: test.txt: Effective permissions does not allow requested access'

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see: Steps to reproduce
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      execute code / programs on account with administrative rights

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: