@@ -45,6 +45,7 @@ class ServerMonitor {
45
45
private final SocketSettings socketSettings ;
46
46
private final ServerSettings settings ;
47
47
private final Mongo mongo ;
48
+ private final PooledConnectionProvider connectionProvider ;
48
49
private int count ;
49
50
private long elapsedNanosSum ;
50
51
private volatile ServerDescription serverDescription ;
@@ -56,12 +57,14 @@ class ServerMonitor {
56
57
57
58
58
59
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 ) {
60
62
this .serverAddress = serverAddress ;
61
63
this .serverStateListener = serverStateListener ;
62
64
this .socketSettings = socketSettings ;
63
65
this .settings = settings ;
64
66
this .mongo = mongo ;
67
+ this .connectionProvider = connectionProvider ;
65
68
serverDescription = getConnectingServerDescription ();
66
69
monitorThread = new Thread (new ServerMonitorRunnable (), "cluster-" + clusterId + "-" + serverAddress );
67
70
monitorThread .setDaemon (true );
@@ -93,6 +96,7 @@ public void run() {
93
96
if (connection != null ) {
94
97
connection .close ();
95
98
connection = null ;
99
+ connectionProvider .invalidate ();
96
100
}
97
101
connection = new DBPort (serverAddress , null , getOptions (), 0 );
98
102
try {
0 commit comments