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

Equality operator of MongoClientSettings is bugged

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Summary

      The bug is very obvious, the equality does not work because you forgot to implement an equality operator for the WriteConcern class and you are using the equality operator inside the Equals method of the MongoClientSettings.
      therefore it uses the default equality (by reference) and fails.

      You might be fooled to think that the equality by reference will still work because you have declared all your WriteConcern types static and use only those.
      but in MongoUrl.GetWriteConcern function

      you are creating a new instance of WriteConcern out side of the "if".

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

       

      version 2.18.0

       

      How to Reproduce

      Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.

       

      ```

      var settings1 = MongoClientSettings.FromConnectionString("mongodb+srv://arik:arik123@test.abcd.mongodb.net/?w=majority"); var settings2 = MongoClientSettings.FromConnectionString("mongodb+srv://arik:arik123@test.abcd.mongodb.net/?w=majority"); Console.WriteLine(settings1 == settings2);

      ```

      Result is false.

       

      Additional Background

      Please provide any additional background information that may be helpful in diagnosing the bug.

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

              Created:
              Updated:
              Resolved: