Skip to content

Commit c329baa

Browse files
committed
Use single connection in async listCollections execution
JAVA-3933
1 parent 36d0e7f commit c329baa

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
import com.mongodb.ReadPreference;
2222
import com.mongodb.ServerAddress;
2323
import com.mongodb.ServerCursor;
24-
import com.mongodb.internal.async.AsyncBatchCursor;
25-
import com.mongodb.internal.async.SingleResultCallback;
2624
import com.mongodb.connection.ConnectionDescription;
2725
import com.mongodb.connection.ServerDescription;
26+
import com.mongodb.internal.async.AsyncBatchCursor;
27+
import com.mongodb.internal.async.SingleResultCallback;
2828
import com.mongodb.internal.binding.AsyncConnectionSource;
2929
import com.mongodb.internal.binding.AsyncReadBinding;
3030
import com.mongodb.internal.binding.ConnectionSource;
@@ -56,7 +56,7 @@
5656
import static com.mongodb.connection.ServerType.SHARD_ROUTER;
5757
import static com.mongodb.internal.async.ErrorHandlingResultCallback.errorHandlingCallback;
5858
import static com.mongodb.internal.operation.CommandOperationHelper.CommandCreator;
59-
import static com.mongodb.internal.operation.CommandOperationHelper.executeCommandAsync;
59+
import static com.mongodb.internal.operation.CommandOperationHelper.executeCommandAsyncWithConnection;
6060
import static com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection;
6161
import static com.mongodb.internal.operation.CommandOperationHelper.isNamespaceError;
6262
import static com.mongodb.internal.operation.CommandOperationHelper.rethrowIfNotNamespaceError;
@@ -262,22 +262,22 @@ public void call(final AsyncConnectionSource source, final AsyncConnection conne
262262
if (t != null) {
263263
errHandlingCallback.onResult(null, t);
264264
} else {
265-
final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback(errHandlingCallback,
266-
source, connection);
267265
if (serverIsAtLeastVersionThreeDotZero(connection.getDescription())) {
268-
executeCommandAsync(binding, databaseName, getCommandCreator(), createCommandDecoder(),
269-
asyncTransformer(), retryReads,
266+
executeCommandAsyncWithConnection(binding, source, databaseName, getCommandCreator(), createCommandDecoder(),
267+
asyncTransformer(), retryReads, connection,
270268
new SingleResultCallback<AsyncBatchCursor<T>>() {
271269
@Override
272270
public void onResult(final AsyncBatchCursor<T> result, final Throwable t) {
273271
if (t != null && !isNamespaceError(t)) {
274-
wrappedCallback.onResult(null, t);
272+
errHandlingCallback.onResult(null, t);
275273
} else {
276-
wrappedCallback.onResult(result != null ? result : emptyAsyncCursor(source), null);
274+
errHandlingCallback.onResult(result != null ? result : emptyAsyncCursor(source), null);
277275
}
278276
}
279277
});
280278
} else {
279+
final SingleResultCallback<AsyncBatchCursor<T>> wrappedCallback = releasingCallback(errHandlingCallback,
280+
source, connection);
281281
connection.queryAsync(getNamespace(), asQueryDocument(connection.getDescription(), binding.getReadPreference()),
282282
null, 0, 0, batchSize, binding.getReadPreference().isSlaveOk(), false, false, false, false, false,
283283
new BsonDocumentCodec(), new SingleResultCallback<QueryResult<BsonDocument>>() {

0 commit comments

Comments
 (0)