Skip to content

Commit 39ec370

Browse files
authored
Fix double connection release on error for drop and create collection operations (#993)
JAVA-4711
1 parent 6cedac5 commit 39ec370

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

driver-core/src/main/com/mongodb/internal/operation/CreateCollectionOperation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ class ProcessCommandsCallback implements SingleResultCallback<Void> {
552552
public void onResult(final Void result, final Throwable t) {
553553
if (t != null) {
554554
finalCallback.onResult(null, t);
555+
return;
555556
}
556557
Function<ConnectionDescription, BsonDocument> nextCommandFunction = commands.poll();
557558
if (nextCommandFunction == null) {

driver-core/src/main/com/mongodb/internal/operation/DropCollectionOperation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import com.mongodb.MongoCommandException;
2020
import com.mongodb.MongoNamespace;
2121
import com.mongodb.WriteConcern;
22-
import com.mongodb.internal.async.SingleResultCallback;
2322
import com.mongodb.connection.ConnectionDescription;
23+
import com.mongodb.internal.async.SingleResultCallback;
2424
import com.mongodb.internal.binding.AsyncReadWriteBinding;
2525
import com.mongodb.internal.binding.AsyncWriteBinding;
2626
import com.mongodb.internal.binding.ReadWriteBinding;
@@ -264,6 +264,7 @@ class ProcessCommandsCallback implements SingleResultCallback<Void> {
264264
public void onResult(final Void result, final Throwable t) {
265265
if (t != null && !isNamespaceError(t)) {
266266
finalCallback.onResult(null, t);
267+
return;
267268
}
268269
Function<ConnectionDescription, BsonDocument> nextCommandFunction = commands.poll();
269270
if (nextCommandFunction == null) {

0 commit comments

Comments
 (0)