Skip to content

Commit e8bc843

Browse files
committed
Add missing condition for whether to sleep in server monitor
There is a missing check in an already-complicated conditinal statement for whether to sleep in the server monitor before executing the next check. The condition is included in the server discovery and monitoring specification pseudo-code but missing in the driver, and there are currently no tests for it. This commits adds the missing condition to the conditional statement. Effectively, this will reduce the number of sockets that the monitor opens on a server that is in the process of shutting down but still accepting connections. JAVA-4730
1 parent d1fec61 commit e8bc843

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

driver-core/src/main/com/mongodb/internal/connection/DefaultServerMonitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void run() {
170170
sdamProvider.get().update(currentServerDescription);
171171

172172
if (((connection == null || shouldStreamResponses(currentServerDescription))
173-
&& currentServerDescription.getTopologyVersion() != null)
173+
&& currentServerDescription.getTopologyVersion() != null && currentServerDescription.getType() != UNKNOWN)
174174
|| (connection != null && connection.hasMoreToCome())
175175
|| (currentServerDescription.getException() instanceof MongoSocketException
176176
&& previousServerDescription.getType() != UNKNOWN)) {

0 commit comments

Comments
 (0)