[JAVA-4917] Command logs don't reflect actual command/reply documents Created: 23/Mar/23  Updated: 28/Oct/23  Resolved: 13/Jun/23

Status: Closed
Project: Java Driver
Component/s: Command Logging and Monitoring
Affects Version/s: None
Fix Version/s: 4.10.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

Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

This code:

        var client = MongoClients.create();
        var coll = client.getDatabase("test").getCollection("dup", JsonObject.class);
        coll.drop();
        coll.insertOne(new JsonObject("{x: 1, x: 2}"));
        System.out.prinlin(coll.find().first().getJson());

outputs

{"_id": {"$oid": "..."}, "x": 1, "x": 2}

but logs:

Command "insert" started on database test using a connection with driver-generated ID 3 and server-generated ID 7946 to localhost:27017. The request ID is 6. Command: {"insert": "dup", "ordered": true, "$db": "test", "documents": [{"x": 2}]}
 
...
Command "find" succeeded in 1.64 ms using a connection with driver-generated ID 3 and server-generated ID 7946 to localhost:27017. The request ID is 7. Command reply: {"cursor": {"firstBatch": [{"_id": {"$oid": "..."}, "x": 2}], "id": 0, "ns": "test.dup"}, "ok": 1.0}
{

Notice that the duplicate `x` field that was actually sent to and received from the server does not appear in the logs.



 Comments   
Comment by Githook User [ 13/Jun/23 ]

Author:

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

Message: ByteBufBsonDocument remains a ByteBuf (#1119)

  • Ensure that ByteBufBsonDocument never hydrates itself into a HashMap
  • Add ByteBufBsonArray and ensure it never hydrates itself into an ArrayList

JAVA-4917
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/2468e98d67c6d73f26e712283f14b92b67dae67c

Comment by Githook User [ 01/Jun/23 ]

Author:

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

Message: Preparatory refactoring (#1123)

  • Remove unused method
  • Suppress warning
  • Inline abstract superclass
  • Remove unnecessary equal/hashCode override

JAVA-4917
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/548bacd3044aa0e97b15bbc10e842ad296073dde

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