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

Invalid ObjectId generated by MongoDB

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.1
    • Component/s: BSON
    • Labels:
      None
    • Environment:
      Cent OS 7

      Add some records to collection with java driver, it will generate object id for each records automatically. In my database, it generate below Object Id by MongoDB:
      ObjectId("58b38f407decdd8070b2df96")

      It's invalid object id, my test:

      import org.bson.types.ObjectId;
      public class Test {
      public static void main(String[] args)

      { // TODO Auto-generated method stub String idStr = "58b38f407decdd8070b2df96"; ObjectId id = new ObjectId(idStr); System.out.println(id.getProcessIdentifier()); }

      }

      Print result:
      -32656

      The processIdentifier is a negative number. Now I map the object id to JSP file, then use JS to generate object id, the new object will contains endash, and it's an invalid object id.

      It happened sometimes but not frequently. The attachment is another invalid object id, notice the processIdentifier value.

      I'm not sure it's a java driver bug or core server bug.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            Kimi KimiLiu [X]
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: