-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.2
-
Component/s: None
-
None
-
Environment:OS X 10.6
A NullPointerException is thrown in DBTCPConnector.close() due to _rsStatus being null when _rsStatus.close() is called.
If you call the constructor
public Mongo( ServerAddress addr , MongoOptions options )
then, the constructor is called:
public DBTCPConnector( Mongo m , ServerAddress addr )
if the ServerAddress is not paired, then the following code sets _rsStatus to null:
if ( addr.isPaired() )
{ _allHosts = new ArrayList<ServerAddress>( addr.explode() ); _rsStatus = new ReplicaSetStatus( m , _allHosts ); _createLogger.info( "switching to replica set mode : " + _allHosts + " -> " + _curMaster ); }else
{ _set( addr ); _allHosts = null; _rsStatus = null; }when DBTCPConnector.close() is eventually called, _rsStatus.close() throws an NPE.
Although _portHolder should never be null, I think it is worth checking it before calling close() on it, as well.
I'll submit a pull request from my fork at http://github.com/RobertStewart/mongo-java-driver.