Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2548

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

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

      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@mongodb.com Ross Lawley
            Reporter:
            rustyx Rustam Abdullaev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: