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

Make sure DisposableMongoClient has a unique underlying Cluster

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Unknown
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Testing
    • Labels:
      None

      Description

      Surprisingly this hasn't happened to us before, but today I wrote a test using a `DisposableMongoClient` that resulted in the rest of the test suite failing.

      The new test looked like this:

      var clientSettings = DriverTestConfiguration.Client.Settings.Clone();
      // make some minor changes to the clientSettings
      using (var client = DriverTestConfiguration.CreateDisposableClient(clientSettings))
      {
          // the test
      }

      What happened was that the changes made to `clientSettings` were minor enough that they did not result in a new underlying `Cluster` being created. So when the `DisposableMongoClient` was `Disposed` so was the underlying `Cluster`.

      But once that happend all other tests that use `DriverTestConfiguration.Client` (which is almost all tests) started failing because that `MongoClient` instance had its `Cluster` disposed out from under it.

      The simplest way to make the `ClusterKey` for ` DisposableMongoClient` unique is to instantiate a new `ClusterConfigurator`, wrapping any existing one.

       

        Attachments

          Activity

            People

            Assignee:
            rstam Robert Stam
            Reporter:
            rstam Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: