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

MongoServerInstance.Disconnect() contains an NRE point

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.1
    • Affects Version/s: 1.0
    • Component/s: None
    • Labels:
      None

      The MongoServerInstance.Disconnect() (yes, it's internal, but it's called from public MongoServer.Disconnect()) does not check connectionPool value before calling connectionPool.Close().
      Since connection might be asynchronous (via ReplicaSetConnector), the MongoServerInstance.Connect() method might still be executing at time the MongoServerInstance.Disconnect() is called.
      This leads to MongoServerInstance.State to be MongoServerState.Conecting, but MongoServerInstance.connectionPool is still null, because, for example, MongoServerAddress.ToIPEndPoint is still resolving that hostname. I think that some additional locking and/or checking is needed to prevent such inconsistencies.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: