GridFSDownloadStreamImpl.skip() can't handle >2GB

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.5.0
    • Affects Version/s: 3.4.2
    • Component/s: GridFS
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      After calling GridFSDownloadStreamImpl.skip() with a value larger than 2GB, e.g. 2306734080, the subsequent read() fails with ArrayIndexOutOfBoundsException.

      It seems like this casting is missing some parentheses at line 117:

              bufferOffset = (int) skippedPosition % chunkSizeInBytes;
      

      This is in effect:

              bufferOffset = ((int) skippedPosition) % chunkSizeInBytes;
      

      But should have been:

              bufferOffset = (int) skippedPosition % chunkSizeInBytes;
      

      The same applies here at line 126:

      Math.floor((float) skippedPosition / chunkSizeInBytes)
      

      (Why float by the way, and not double?)

            Assignee:
            Ross Lawley
            Reporter:
            Rustam Abdullaev
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: