-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Legacy API
-
None
-
Not Needed
Summary
The DBObject Decoder instance that is used to decode the respond in DB.command comes from the default codec registry rather than the registry from the MongoClient. The registry from MongoClient must be used in order to decode UUID instance according to the configured UuidRepresentation.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
How to Reproduce
MongoClient client = new MongoClient(getMongoClientSettingsBuilder() .uuidRepresentation(UuidRepresentation.STANDARD) .build())) { UUID id = UUID.randomUUID(); DB db = client.getDB(getDefaultDatabaseName()); db.getCollection(collectionName).insert(new BasicDBObject("_id", id)); DBObject reply = db.command(new BasicDBObject("findAndModify", collectionName) .append("query", new BasicDBObject("_id", id)) .append("remove", true));
Expected behavior: The UUID in the command should be encoded with STANDARD representation, and the UUID in the command reply should be decoded with STANDARD representation.
Actual behavior: the driver throws an exception indicating that the configured UUID representation has not been applied.