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

DB#command encoding and decoding does not apply UUID representation

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.5.0
    • 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.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: