Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-396

RAM FileSystem allows the file system size to exceed the max size limit.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      All

      Description

      When a new file is created in the RAM file system, and content is written to its outputstream, there is a check in place for ensuring that file system size does not exceed the max limit set. But that check is wrong.

      In RamFileOutputStream.write(), you calculate the size, newsize and call file.resize(newSize)
      And in the RamFileObject.resize(), there is a check
      if (fs.size() + newSize - this.size() > maxSize)

      { throw new IOException("FileSystem capacity (" + maxSize + ") exceeded."); }

      This check is wrong.
      Consider this case of a new file system where the file system size is set to 5 MB and I am trying to create a file of 10 MB in the RAM file system. the file is being written in the chunk of 8 kb. For every resize check, fs.size() would be 0 and (newsize - this.size()) would be 8 kb and therefore the check never passes.

      It could have been correct if the "old size" was locked down to the size that was registered with the file system but the old size (this.size()) keeps changing at every write. Thus the difference in newSize and this.size() would always be the chunk size (typically 8 kb) and therefore no exception would be thrown ever.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              rupesh106 Rupesh Kumar
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified