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

Invalid ObjectId generated by MongoDB

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • 3.4.1
    • BSON
    • None
    • Cent OS 7

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: