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

Facing a 'no more' RuntimeException on DBCursor#next() when DBCursor#count() == 1

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

      Hello,

      I am reading data from mongo in Java, with this code:

      DBObject dbo = new BasicDBObject(LOCKED_DOC_ID_FIELD, gdto.getDocId());
      DBCursor lock = locks.find(dbo);
      if (lock.count() == 1) {
      	DBObject lockDBO = lock.next();
      	long createdAtTS = (Long) lockDBO.get(CREATED_AT_FIELD);
      	Date d = new Date(createdAtTS);
      	return new Lock(gdto, d);
      } else if (lock.count() > 1) {
      	throw new IllegalStateException("It seems like mongoDB locks.locks collection does not have a unique index on lockedId. Do: use locks; db.locks.ensureIndex({lockedDocId:1}, {unique:true})");
      			}
      

      I somtimes get an Exception on `DBObject lockDBO = lock.next();`:

      java.lang.RuntimeException: no more
      at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:388)
      at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:350)
      at com.mongodb.DBCursor._next(DBCursor.java:421)
      at com.mongodb.DBCursor.next(DBCursor.java:494)

      How can this be?

      Thanks for your precious help.
      Brice.

            Assignee:
            Unassigned Unassigned
            Reporter:
            blaurencin@bestofmedia.com Brice Laurencin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: