@@ -45,6 +45,7 @@ class ServerMonitor {
4545 private final SocketSettings socketSettings ;
4646 private final ServerSettings settings ;
4747 private final Mongo mongo ;
48+ private final PooledConnectionProvider connectionProvider ;
4849 private int count ;
4950 private long elapsedNanosSum ;
5051 private volatile ServerDescription serverDescription ;
@@ -56,12 +57,14 @@ class ServerMonitor {
5657
5758
5859 ServerMonitor (final ServerAddress serverAddress , final ChangeListener <ServerDescription > serverStateListener ,
59- final SocketSettings socketSettings , final ServerSettings settings , final String clusterId , Mongo mongo ) {
60+ final SocketSettings socketSettings , final ServerSettings settings , final String clusterId , Mongo mongo ,
61+ final PooledConnectionProvider connectionProvider ) {
6062 this .serverAddress = serverAddress ;
6163 this .serverStateListener = serverStateListener ;
6264 this .socketSettings = socketSettings ;
6365 this .settings = settings ;
6466 this .mongo = mongo ;
67+ this .connectionProvider = connectionProvider ;
6568 serverDescription = getConnectingServerDescription ();
6669 monitorThread = new Thread (new ServerMonitorRunnable (), "cluster-" + clusterId + "-" + serverAddress );
6770 monitorThread .setDaemon (true );
@@ -93,6 +96,7 @@ public void run() {
9396 if (connection != null ) {
9497 connection .close ();
9598 connection = null ;
99+ connectionProvider .invalidate ();
96100 }
97101 connection = new DBPort (serverAddress , null , getOptions (), 0 );
98102 try {
0 commit comments