Skip to content

Commit 5dbfb40

Browse files
committed
JAVA-381: Partially reverted last change. The synchronization does have to be outside the null check, otherwise it's a race condition and the notification may never be received
1 parent bf23750 commit 5dbfb40

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/com/mongodb/DynamicConnectionStatus.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,10 @@ public CommandResult update() {
178178
private boolean isMongos;
179179
}
180180

181-
private ConnectionStatus getConnectionStatus() {
181+
private synchronized ConnectionStatus getConnectionStatus() {
182182
if (connectionStatus == null) {
183183
try {
184-
synchronized (this) {
185-
wait(_mongoOptions.connectTimeout);
186-
}
184+
wait(_mongoOptions.connectTimeout);
187185
} catch (InterruptedException e) {
188186
throw new MongoException("Interrupted while waiting for next update to dynamic status", e);
189187
}

0 commit comments

Comments
 (0)