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

LocalFileRandomAccessContent returning wrong value when reading 0xFF

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.0, 2.1
    • 2.7.0
    • Important

    Description

      The LocalFileRandomAccessContent InputStream used for reading a byte as an int is calling the RandomAccessFile method readByte(byte), so it returns -1 in case of EOFException, but also in case of reading 0xFF in a file.

      This also violates the expected behaviour of the read() method of the InputStream as can return negative values as result of the casting, while should only return an int value beetween 0 and 255, or -1 in case of eof.

      This problem is also inherited by the default read(byte[]) and read(byte[], int off, int length).

      The solution is to change the implementation to:
      raf.read();

      Pull request: https://github.com/apache/commons-vfs/pull/17

      Attachments

        Activity

          People

            Unassigned Unassigned
            davidgoitia David Goitia Amigo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 0h
                0h
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m