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

Files:isDirectory and isRegularFile methods not throwing SecurityException

    XMLWordPrintable

Details

    • b05
    • b06
    • Verified

    Description

      Couple of JCK tests are failing validating the assertion:
      "https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/nio/file/Files.html#isDirectory(java.nio.file.Path,java.nio.file.LinkOption...)"

      "Throws:
      SecurityException - In the case of the default provider, and a security manager is installed, its checkRead method denies read access to the file."

      The tests are failing -
      api/java_nio/file/Files/FilesTests.html[isDirectory_03, isRegularFile_03]

      possibly regression caused by - https://bugs.openjdk.org/browse/JDK-8283335 in JDKb20-b05

      Attached a standalone code which runs with supplied SecurityManager.

      Note - It works fine with JDK20-b04.

      JDKb20-b04 - Throws SecurityException As expected and checkRead invoked.
      ====
      /scratch/jdk-cache/20/4/jdk-20/bin/java -Djava.security.manager=MySecurityManager TestFilesSecEx
      WARNING: A command line option has enabled the Security Manager
      WARNING: The Security Manager is deprecated and will be removed in a future release
       The value is java.system.class.loader
       The value is setContextClassLoader
       The value is modifyThreadGroup
       The value is sun.jnu.encoding
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class
       -- CheckRead is invoked --
       The value is C:\Diffs
      Exception in thread "main" java.lang.SecurityException: MyException
              at MySecurityManager.checkPermission(MySecurityManager.java:8)
              at java.base/java.lang.SecurityManager.checkRead(SecurityManager.java:751)
              at MySecurityManager.checkRead(MySecurityManager.java:14)
              at java.base/sun.nio.fs.UnixPath.checkRead(UnixPath.java:780)
              at java.base/sun.nio.fs.UnixFileSystemProvider.isDirectory(UnixFileSystemProvider.java:521)
              at java.base/java.nio.file.Files.isDirectory(Files.java:2316)
              at TestFilesSecEx.test01(TestFilesSecEx.java:12)
              at TestFilesSecEx.main(TestFilesSecEx.java:7)

      ============
      JDKb20-b05 - Does not Throws SecurityException as checkRead is not invoked.

      /scratch/jdk-cache/20/5/jdk-20/bin/java -Djava.security.manager=MySecurityManager TestFilesSecEx
      WARNING: A command line option has enabled the Security Manager
      WARNING: The Security Manager is deprecated and will be removed in a future release
       The value is java.system.class.loader
       The value is setContextClassLoader
       The value is modifyThreadGroup
       The value is sun.jnu.encoding
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class
       -- CheckRead is invoked --
       The value is /scratch/kganapur/TestFIles/TestFilesSecEx.class






      Attachments

        1. 8289984.patch
          2 kB
        2. MySecurityManager.java
          0.5 kB
        3. TestFilesSecEx.java
          0.3 kB

        Issue Links

          Activity

            People

              lancea Lance Andersen
              kganapureddy Krushnareddy Ganapureddy
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: