Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-6034

[classlib] [luni] Should Improve File System Exception Messages

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.0M8
    • 5.0M9
    • Classlib
    • None
    • Moderate

    Description

      Given a test scenario [1] where "t:" is a mapped drive letter to which the current user only has R+E access but doesn't have W acess.
      Conduct this on RI [2] and HARMONY [3]. Obviously, RI return a FileNotFoundException with a "Access is denied" message while HARMONY does not provide information as to why the file is not found. This also occurs when the corresponding file doesn't exist, RI will throw FNF with "system fails to find ...".

      I think there is a difference in information returned that makes it a bit easier to understand why the FNF Exception is occurring.
      Should we improve this?

      [1]
      public static void main(String[] args) {
      try {
      File f = new File("t:/temp.file");
      if (f.exists())

      { System.out.println("File " + f.getAbsolutePath() + " exists"); }

      FileOutputStream fos = new FileOutputStream(f);
      fos.write("Hello, World!".getBytes());
      fos.close();
      } catch (FileNotFoundException fnfe)

      { fnfe.printStackTrace(System.err); }

      catch (Throwable t)

      { t.printStackTrace(System.err); }

      }

      [2] Output from a FileNotFoundException on RI:
      java.io.FileNotFoundException: t:/temp.file (Access is denied)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:201)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:153)
      at test.Main.main(Main.java:23)

      [3] Output from a FileNotFoundException on HARMONY:
      java.io.FileNotFoundException: t:/temp.file
      at java.io.FileOutputStream.<init>(Unknown Source)
      at java.io.FileOutputStream.<init>(Unknown Source)
      at test.Main.main(Main.java:23)

      Attachments

        1. HARMONY-6034.diff
          10 kB
          Regis Xu
        2. HARMONY-6034.v2.diff
          10 kB
          Regis Xu

        Activity

          People

            Unassigned Unassigned
            zhoukevin Kevin Zhou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: