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