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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.9.3
    • Fix Version/s: None
    • Component/s: API
    • Labels:
    • Environment:

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: