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

HttpRequest.BodyPublishers#ofFile(Path) assumes the default file system

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      behavioral
    • Compatibility Risk:
      minimal
    • Compatibility Risk Description:
      Java doc change only to clarify behaviour
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Specify a file system related constraint in the existing @throws declaration of HttpRequest.BodyPublisher::ofFile.

      Problem

      The original specification of BodyPublisher::ofFile assumed that the given path belongs to the default file system or behaves as such, and would fail if this was not the case. A fix is proposed to enable BodyPublisher::ofFile to work with other file system path implementations. Accordingly, a specification change should clarify when a SecurityException is thrown, depending on the file system of the given path.

      Solution

      Specify the conditions of when a SecurityException is thrown, which is only in the case of the system-default file system provider.

      Specification

      java.net.http.HttpRequest.BodyPublishers

       -    * @throws SecurityException if a security manager has been installed
       -    *          and it denies {@link SecurityManager#checkRead(String)
       -    *          read access} to the given file
       +    * @throws SecurityException if opening the file for reading is denied:
       +    *         in the case of the system-default file system provider, and
       +    *         a security manager is installed,
       +    *         {@link SecurityManager#checkRead(String) checkRead}
       +    *         is invoked to check read access to the given file
            */
           public static BodyPublisher ofFile(Path path) throws FileNotFoundException {

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jboes Julia Boes
                Reporter:
                webbuggrp Webbug Group
                Reviewed By:
                Chris Hegarty, Daniel Fuchs
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: