Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-4799

Pipeline stage with BsonDocumentSearchDefinition can be rendered only once

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.22.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • Hide

      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?

      Show
      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?

      The issue as described to me by Boris is that if a caller to Render modifies the returned BsonDocument then a subsequent call to Render returns the modified BsonDocument.

      This could be resolved by clarifying ownership rules of the mutable BsonDocument. Only the owner of the BsonDocument should modify it.

      Most likely this would mean that that BsonDocumentSearchDefinition should own the BsonDocument, which in turn means that callers to Render should not modify the returned BsonDocument because they don't own it. However, such a rule can't be enforced at compile time because BsonDocument is mutable.

      Alternatively, BsonDocumentSearchDefinition could make a defensive copy of the BsonDocument before returning it from Render (and possibly in the constructor as well to protect the document even further). This approach would be safe but involves more memory allocations.

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            boris.dogadov@mongodb.com Boris Dogadov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: