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

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

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.1
    • Affects Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved: