Harmony
  1. Harmony
  2. HARMONY-517

[classlib][luni] File.listFiles returns empty list but should return null

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      On unix, if I create a directory and then change the permissions to make it unreadable ("chmod 0 dir") then File.listFiles() on that directory on RI returns null but on Harmony it returns the empty list.

      1. reading.chmod.0.directory.diff
        1 kB
        Mark Hindess
      2. Harmony-517.diff
        1 kB
        Ruth Cao

        Issue Links

          Activity

          Hide
          Alexei Zakharov added a comment -

          Fix was verified by Ruth. Issue closed.

          Show
          Alexei Zakharov added a comment - Fix was verified by Ruth. Issue closed.
          Hide
          Ruth Cao added a comment -

          Thanks, Alexei. The fix looks fine.

          Show
          Ruth Cao added a comment - Thanks, Alexei. The fix looks fine.
          Hide
          Alexei Zakharov added a comment -

          Ruth, I've analyzed your patch and found that there are several other methods like list(FileNameFilter) and listFiles() in File.java that also could/should be fixed in the same way. Another thing I've discovered is the fact that File.canRead() does nothing on Windows currently (you use canRead() in your patch).

          So I've created my own fix that is based on yours. It fixes all list methods of File class and add functionality to the Windows version of getPlatformIsWriteOnly() native method from "luni/windows/helpers.c". The fix was committed at the revision 541367. Please verify it solves the original problem.

          Show
          Alexei Zakharov added a comment - Ruth, I've analyzed your patch and found that there are several other methods like list(FileNameFilter) and listFiles() in File.java that also could/should be fixed in the same way. Another thing I've discovered is the fact that File.canRead() does nothing on Windows currently (you use canRead() in your patch). So I've created my own fix that is based on yours. It fixes all list methods of File class and add functionality to the Windows version of getPlatformIsWriteOnly() native method from "luni/windows/helpers.c". The fix was committed at the revision 541367. Please verify it solves the original problem.
          Hide
          Ruth Cao added a comment -

          Hello,
          I'm looking into this issue and it seems that we can use File.canRead() to filter this kind of situation. Alexey, may you pls try this patch? Thanks.

          Besides, it might be easy to write a test case for this issue in java 6 since it provides a new method called File.setReadable. Maybe we can add it in java6 branch in the future

          Show
          Ruth Cao added a comment - Hello, I'm looking into this issue and it seems that we can use File.canRead() to filter this kind of situation. Alexey, may you pls try this patch? Thanks. Besides, it might be easy to write a test case for this issue in java 6 since it provides a new method called File.setReadable. Maybe we can add it in java6 branch in the future
          Hide
          Alexey Petrenko added a comment -

          Mark,

          Harmony with your patch return null even in case of empty dir. But RI returns array in this case.
          So your patch can not be applied...

          Show
          Alexey Petrenko added a comment - Mark, Harmony with your patch return null even in case of empty dir. But RI returns array in this case. So your patch can not be applied...
          Hide
          Mark Hindess added a comment -

          Patch with fix. No test, how should this be tested?

          Show
          Mark Hindess added a comment - Patch with fix. No test, how should this be tested?

            People

            • Assignee:
              Alexei Zakharov
              Reporter:
              Mark Hindess
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development