[CSHARP-233] MongoServerInstance.Disconnect() contains an NRE point Created: 27/May/11  Updated: 02/Apr/15  Resolved: 08/Jun/11

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.0
Fix Version/s: 1.1

Type: Bug Priority: Minor - P4
Reporter: Aristarkh Zagorodnikov Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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.



 Comments   
Comment by Robert Stam [ 08/Jun/11 ]

Disconnect now checks that connectionPool is not null before calling Close.

Generated at Wed Feb 07 21:36:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.