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

GridFSDownloadPublisher can't handle > 2 GB

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.1
    • Affects Version/s: 3.12.1
    • Component/s: Reactive Streams
    • None

      After upgrading to Java driver 3.12 and using the Reactive Streams-based asynchronous driver, it is not possible anymore to download files bigger than 2 GB. In the older version using GridFSDownloadStream it was supported, however GridFSDownloadPublisherImpl is limited by int. The code breaks here on allocate when exceeding max value 2147483647, then the remaining intValue() becomes negative:

                          int byteBufferSize = Math.max(chunkSize, bufferSizeBytes);
                          byteBufferSize =  Math.min(Long.valueOf(remaining).intValue(), byteBufferSize);
                          ByteBuffer byteBuffer = ByteBuffer.allocate(byteBufferSize);

      Is it possible to use long instead of int for the byte buffer to avoid this?

      See also related Jira where it was fixed to handle larger files in the old implementation of GridFSDownloadStreamImpl: https://jira.mongodb.org/browse/JAVA-2548

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            tamara.ockhuijsen@klm.com Tamara Ockhuijsen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: