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

(fs) Files.createTempDirectory should say something about the default file permissions when no file attributes specified

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 25
    • core-libs
    • None
    • behavioral
    • minimal
    • Minimal risk as this merely clarifies existing behavior.
    • Java API
    • SE

      Summary

      Improve the specification of Files.createTempDirectory(Path,String,FileAttribute<?>...) for the case when no attributes are specified.

      Problem

      Unlike the related method Files.createTempFile(Path,String,String,FileAttribute<?>...), Files.createTempDirectory(Path,String,FileAttribute<?>...) does not make clear that the directory created may have restrictive permissions if the FileAttribute<?>... parameter is null.

      Solution

      Add a sentence clarifying the behavior of Files.createTempDirectory(Path,String,FileAttribute<?>...) when no attributes are specified.

      Specification

      --- a/src/java.base/share/classes/java/nio/file/Files.java
      +++ b/src/java.base/share/classes/java/nio/file/Files.java
      @@ -860,7 +860,10 @@ public static Path createTempFile(String prefix,
            * file-attributes} to set atomically when creating the directory. Each
            * attribute is identified by its {@link FileAttribute#name name}. If more
            * than one attribute of the same name is included in the array then all but
      -     * the last occurrence is ignored.
      +     * the last occurrence is ignored. When no file attributes are specified,
      +     * then the resulting directory may have more restrictive access
      +     * permissions to directories created by the
      +     * {@linkplain Files#createDirectory(Path, FileAttribute<?>...)} method.
            *
            * @param   dir
            *          the path to directory in which to create the directory

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

              Created:
              Updated:
              Resolved: