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

ArrayIndexOutOfBoundsException at GridFSInputFile.java:353 when using chunksize > 256KB in GridFS

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0
    • Affects Version/s: 2.6.3
    • Component/s: API
    • None

      To produce the exception:


      Mongo mongo = new Mongo("localhost", 27017);
      GridFS gfs = new GridFS(mongo.getDB("bucket_test"));
      GridFSInputFile file = gfs.createFile("512kb_bucket");
      file.setChunkSize(512 * 1024);
      OutputStream os = file.getOutputStream();
      for (int i=0; i<32 * 1024 * 1024; i++)

      { os.write('.'); }

      os.close();
      mongo.close();


      It appears that the private _buffer[] in GridFSInputFile.java should be resized as well in the setChunkSize(long _chunkSize) method. Eg.


      public void setChunkSize(long _chunkSize)

      { if (_outputStream != null || _savedChunks) return; this._chunkSize = _chunkSize; _buffer = new byte[(int) _chunkSize]; // ######## Resize here? ######## }


            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            joongonn Joong Onn
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: