Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-319

FileUtils.sizeOfDirectory follows symbolic links.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.4
    • Component/s: None
    • Labels:
      None

      Description

      First of all Thanks tons Apache Commons folks for all the amazing work! My first JIRA. Yayyy. I contributed B-)

      A symbolic link may create a cycle and so sizeOfDirectory crashes with an IllegalArgumentException. e.g.

      $ tree test
      test
      ├── file
      └── ravi
          ├── cycle -> ../../test
          └── file
      

      causes FileUtils.sizeOfDirectory to crash like so

      java TestJAVA
      Exception in thread "main" java.lang.IllegalArgumentException: <somepath>/test/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle/ravi/cycle does not exist
              at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2053)
              at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
              at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
              at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
              at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
              at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
              at org.apache.commons.io.FileUtils.sizeOf(FileUtils.java:2057)
              at org.apache.commons.io.FileUtils.sizeOfDirectory(FileUtils.java:2089)
      

      We faced the same issue in Hadoop . Checkout https://issues.apache.org/jira/browse/HADOOP-6963 for our solution

        Attachments

        1. commons-io-319.patch
          1 kB
          Ravi Prakash
        2. commons-io-319.patch
          2 kB
          Ravi Prakash

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              raviprak Ravi Prakash
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: