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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.4.2
    • Fix Version/s: 3.5.0
    • Component/s: GridFS
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      JVM Sprint 40

      Description

      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?)

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: