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

ObjectID.isValid(String) only checks lower bounds on String

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • 2.1
    • 2.0
    • None
    • None

    Description

      ObjectID.isValid(String) will return true for Strings that are longer than are used for building the ObjectID. ObjectID.isValid(String) checks that a String is at least 18 characters long and looks like hex encoding. For hex Strings that are longer than 18 it will also return true. But when constructing the ObjectId(String) it will only use the first 18 characters.

      I am expecting that a String that is longer than 18 characters will not be valid as per ObjectID.isValid(String).

      This comes up in the context of the Morphia ORM utility that uses ObjectID.isValid(String) when mapping an _id for a DBObject. An exception is thrown when the toString() of the stored ObjectID does not match the String with which the ObjectID was built.

      Attachments

        Activity

          People

            eliot Eliot Horowitz (Inactive)
            clintpells Clint Pells
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: