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

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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.8.0
    • 2.6.3
    • API
    • None

    Description

      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? ######## }


      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: