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

Files.exists javadoc doesn't mention eating IOException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 14
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b19
    • Verification:
      Verified

      Description

      A DESCRIPTION OF THE PROBLEM :
      The documentation for Files.exists does not mention, except obliquely, that it eats IOException. By contrast, the Files.isDirectory method says "Where it is required to distinguish an I/O exception from the case that the file is not a directory then the file attributes can be read with..."

      (I say "obliquely" because the docs do say "... the file does not exist or its existence cannot be determined." -- this, in my view, requires some reading between the lines).

      Incidentally, I think that entire family of IOException-eating functions should be deprecated. Eating FileNotFoundException (ENOENT or ENOTDIR), is reasonable for these functions. Eating EIO is basically never what you want. So as well as clarifying the javadoc, it would be OK with me to replace the entire range of functions with safe replacements.

      The documentation may be clarified by adding a link to FileSystemProvider.checkAccess() which explains the exceptions which it can throw.


        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: