[JAVA-4450] DB#command encoding and decoding does not apply UUID representation Created: 25/Jan/22  Updated: 28/Oct/23  Resolved: 27/Jan/22

Status: Closed
Project: Java Driver
Component/s: Legacy API
Affects Version/s: None
Fix Version/s: 4.5.0

Type: Bug Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Documentation Changes: Not Needed

 Description   

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.



 Comments   
Comment by Githook User [ 27/Jan/22 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Apply configured uuid representation to DB#command encoding and decoding (#861)

JAVA-4450
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/4e609472d826894ac455f1770af54ae3ff5ee227

Generated at Thu Feb 08 09:02:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.