Skip to content

Commit 0ab988b

Browse files
committed
JAVA-1159: null out the connection before trying to construct it again.
1 parent a3fd1f3 commit 0ab988b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/com/mongodb/ServerStateNotifier.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public synchronized void run() {
7575
// down
7676
count = 0;
7777
elapsedNanosSum = 0;
78-
connection.close(); // generating a warning in IDEA about possible NPE, but I don't think it can happen
78+
if (connection != null) {
79+
connection.close();
80+
connection = null;
81+
}
7982
connection = new DBPort(serverAddress, null, getOptions(), 0);
8083
try {
8184
serverDescription = lookupServerDescription();

0 commit comments

Comments
 (0)