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

Missing filter criteria on CommandStartedEvent when run old DB versions <3.2

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Monitoring
    • Labels:
      None

      Description

      When the following code is executed against a version of the database earlier than 3.2 where a CommandListener has been configured, the filter criteria is omitted from the CommandStartedEvent when a $comment has been manually added to the query:

      MongoClient mongoClient = new MongoClient("localhost", options);
      MongoDatabase test = mongoClient.getDatabase("test");
      MongoCollection<Document> coll = test.getCollection("TestCollection");
       
      coll.insertOne(new Document("a", 1));
      coll.find(new Document("a", 1)).modifiers(new Document("$comment", "test")).first();
      coll.find(new Document("a", 1).append("$comment", "test")).first();
      

      Against 3.2, the following output is seen:

      { "insert" : "TestCollection", "ordered" : true, "documents" : [{ "_id" : { "$oid" : "57594e2ce97b981da4837eb1" }, "a" : 1 }] }
      { "find" : "TestCollection", "comment" : "test", "filter" : { "a" : 1 }, "limit" : 1, "singleBatch" : true }
      { "find" : "TestCollection", "filter" : { "a" : 1, "$comment" : "test" }, "limit" : 1, "singleBatch" : true }
      

      Against 2.6 or 3.0, the output is:

      { "insert" : "TestCollection", "ordered" : true, "documents" : [{ "_id" : { "$oid" : "57595531e97b981dd04c719b" }, "a" : 1 }] }
      { "find" : "TestCollection", "comment" : "test", "filter" : { "a" : 1 }, "limit" : -1 }
      { "find" : "TestCollection", "comment" : "test", "limit" : -1 }
      

      A source file is attached which when compiled reliable reproduces the issue.

      This was tested against version 3.2.2 of the driver.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: