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

buffer overrun for large documents causes an exception for DBCursor.hasNext()

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      WinXP, Java SE 6u13, Mongo Java driver mongo-0.7.jar

      I have some large documents (representing the contents of files in the 250K-1MB range) that cannot be read with the Java driver. The failure happens with DBCursor.hasNext():

      public void catalog()
      {
      DBObject mdref = new BasicDBObject();
      mdref.put("metadata", 1);
      DBCursor cursor = this.coll.find();
      // the above line causes an error (the following line works ok)
      // DBCursor cursor = this.coll.find(new BasicDBObject(), mdref);
      System.out.println("Found "cursor.count()" objects.");
      while (cursor.hasNext())

      { DBObject obj = cursor.next(); System.out.println(obj); }

      }

      When I run this on my database collection, I get the following. The call to find() succeeds, and the cursor's count() method works ok, but it bombs on the first hasNext() call, looks like some kind of buffer overrun.

      Found 10 objects.
      Exception in thread "main" java.lang.IndexOutOfBoundsException
      at java.nio.Buffer.checkBounds(Unknown Source)
      at java.nio.DirectByteBuffer.get(Unknown Source)
      at com.mongodb.ByteDecoder.decodeNext(ByteDecoder.java:189)
      at com.mongodb.ByteDecoder.readObject(ByteDecoder.java:103)
      at com.mongodb.DBApiLayer$SingleResult.<init>(DBApiLayer.java:538)
      at com.mongodb.DBApiLayer$MyCollection.find(DBApiLayer.java:419)
      at com.mongodb.DBCursor._check(DBCursor.java:214)
      at com.mongodb.DBCursor._hasNext(DBCursor.java:322)
      at com.mongodb.DBCursor.hasNext(DBCursor.java:347)
      at com.dekaresearch.tools.datasheets.Manager.catalog(Manager.java:45)
      at com.dekaresearch.tools.datasheets.Manager$Action$2.execute(Manager.java:21)
      at com.dekaresearch.tools.datasheets.Manager.main(Manager.java:69)

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            jmsachs Jason Sachs
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: