Skip to content

Commit 7db464c

Browse files
committed
Just use ReentrantLock
1 parent 026cec7 commit 7db464c

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import java.util.List;
4646
import java.util.concurrent.atomic.AtomicBoolean;
4747
import java.util.concurrent.atomic.AtomicInteger;
48-
import java.util.concurrent.locks.ReentrantLock;
4948

5049
import static com.mongodb.assertions.Assertions.assertNotNull;
5150
import static com.mongodb.assertions.Assertions.assertTrue;
@@ -55,9 +54,9 @@
5554
import static com.mongodb.internal.operation.CommandBatchCursorHelper.MESSAGE_IF_CONCURRENT_OPERATION;
5655
import static com.mongodb.internal.operation.CommandBatchCursorHelper.NEXT_BATCH;
5756
import static com.mongodb.internal.operation.CommandBatchCursorHelper.NO_OP_FIELD_NAME_VALIDATOR;
58-
import static com.mongodb.internal.operation.CommandBatchCursorHelper.logCommandCursorResult;
5957
import static com.mongodb.internal.operation.CommandBatchCursorHelper.getKillCursorsCommand;
6058
import static com.mongodb.internal.operation.CommandBatchCursorHelper.getMoreCommandDocument;
59+
import static com.mongodb.internal.operation.CommandBatchCursorHelper.logCommandCursorResult;
6160
import static com.mongodb.internal.operation.CommandBatchCursorHelper.translateCommandException;
6261
import static java.util.Collections.emptyList;
6362

@@ -252,7 +251,7 @@ private static final class ResourceManager extends CursorResourceManager<AsyncCo
252251
final AsyncConnectionSource connectionSource,
253252
@Nullable final AsyncConnection connectionToPin,
254253
@Nullable final ServerCursor serverCursor) {
255-
super(new ReentrantLock(), namespace, connectionSource, connectionToPin, serverCursor);
254+
super(namespace, connectionSource, connectionToPin, serverCursor);
256255
}
257256

258257
/**

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
import java.util.List;
4141
import java.util.NoSuchElementException;
42-
import java.util.concurrent.locks.StampedLock;
4342
import java.util.function.Consumer;
4443
import java.util.function.Supplier;
4544

@@ -53,8 +52,8 @@
5352
import static com.mongodb.internal.operation.CommandBatchCursorHelper.NEXT_BATCH;
5453
import static com.mongodb.internal.operation.CommandBatchCursorHelper.NO_OP_FIELD_NAME_VALIDATOR;
5554
import static com.mongodb.internal.operation.CommandBatchCursorHelper.getKillCursorsCommand;
56-
import static com.mongodb.internal.operation.CommandBatchCursorHelper.logCommandCursorResult;
5755
import static com.mongodb.internal.operation.CommandBatchCursorHelper.getMoreCommandDocument;
56+
import static com.mongodb.internal.operation.CommandBatchCursorHelper.logCommandCursorResult;
5857
import static com.mongodb.internal.operation.CommandBatchCursorHelper.translateCommandException;
5958

6059
class CommandBatchCursor<T> implements AggregateResponseBatchCursor<T> {
@@ -292,7 +291,7 @@ private static final class ResourceManager extends CursorResourceManager<Connect
292291
final ConnectionSource connectionSource,
293292
@Nullable final Connection connectionToPin,
294293
@Nullable final ServerCursor serverCursor) {
295-
super(new StampedLock().asWriteLock(), namespace, connectionSource, connectionToPin, serverCursor);
294+
super(namespace, connectionSource, connectionToPin, serverCursor);
296295
}
297296

298297
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.mongodb.lang.Nullable;
2626

2727
import java.util.concurrent.locks.Lock;
28+
import java.util.concurrent.locks.ReentrantLock;
2829

2930
import static com.mongodb.assertions.Assertions.assertNotNull;
3031
import static com.mongodb.assertions.Assertions.assertNull;
@@ -65,12 +66,11 @@ abstract class CursorResourceManager<CS extends ReferenceCounted, C extends Refe
6566
private volatile boolean skipReleasingServerResourcesOnClose;
6667

6768
CursorResourceManager(
68-
final Lock lock,
6969
final MongoNamespace namespace,
7070
final CS connectionSource,
7171
@Nullable final C connectionToPin,
7272
@Nullable final ServerCursor serverCursor) {
73-
this.lock = notNull("lock", lock);
73+
this.lock = new ReentrantLock();
7474
this.namespace = notNull("mongoNamespace", namespace);
7575
this.state = State.IDLE;
7676
if (serverCursor != null) {

0 commit comments

Comments
 (0)