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

FileContent#getByteArray() throws IllegalArgumentException: Buffer size <= 0 when file size is 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4
    • 2.4.1
    • None

    Description

      The current code only checks for a size bigger than 2MB but ignores when the returned size is 0 or negative. sizeL will be typically equals to zero if the request is made to a WebServer and the response generated live (like PHP). Then the getInputStream(size) will fail in this case when the size is really used by the implementation.

          default byte[] getByteArray() throws IOException {
              final long sizeL = getSize();
              if (sizeL > Integer.MAX_VALUE) {
                  throw new IllegalStateException(String.format("File content is too large for a byte array: %,d", sizeL));
              }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wrey75 William Rey
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m