-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0
-
Component/s: None
-
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.