Skip to content

Commit 893d419

Browse files
committed
Use "create" prefix consistently.
1 parent 85cc1aa commit 893d419

77 files changed

Lines changed: 451 additions & 463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

driver-core/src/test/functional/com/mongodb/ClusterFixture.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ public static ServerVersion getServerVersion() {
193193
if (serverVersion == null) {
194194
serverVersion = getVersion(new CommandReadOperation<>("admin",
195195
new BsonDocument("buildInfo", new BsonInt32(1)), new BsonDocumentCodec())
196-
.execute(new ClusterBinding(getCluster(), ReadPreference.nearest()), getOperationContext()));
196+
.execute(new ClusterBinding(getCluster(), ReadPreference.nearest()), createOperationContext()));
197197
}
198198
return serverVersion;
199199
}
200200

201-
public static OperationContext getOperationContext() {
201+
public static OperationContext createOperationContext() {
202202
return new OperationContext(
203203
IgnorableRequestContext.INSTANCE,
204204
new ReadConcernAwareNoOpSessionContext(ReadConcern.DEFAULT),
@@ -257,7 +257,7 @@ public static boolean hasEncryptionTestsEnabled() {
257257
public static Document getServerStatus() {
258258
return new CommandReadOperation<>("admin", new BsonDocument("serverStatus", new BsonInt32(1)),
259259
new DocumentCodec())
260-
.execute(getBinding(), getOperationContext());
260+
.execute(getBinding(), createOperationContext());
261261
}
262262

263263
public static boolean supportsFsync() {
@@ -272,7 +272,7 @@ static class ShutdownHook extends Thread {
272272
public void run() {
273273
if (cluster != null) {
274274
try {
275-
new DropDatabaseOperation(getDefaultDatabaseName(), WriteConcern.ACKNOWLEDGED).execute(getBinding(), getOperationContext());
275+
new DropDatabaseOperation(getDefaultDatabaseName(), WriteConcern.ACKNOWLEDGED).execute(getBinding(), createOperationContext());
276276
} catch (MongoCommandException e) {
277277
// if we do not have permission to drop the database, assume it is cleaned up in some other way
278278
if (!e.getMessage().contains("Command dropDatabase requires authentication")) {
@@ -324,7 +324,7 @@ public static synchronized ConnectionString getConnectionString() {
324324
try {
325325
BsonDocument helloResult = new CommandReadOperation<>("admin",
326326
new BsonDocument(LEGACY_HELLO, new BsonInt32(1)), new BsonDocumentCodec())
327-
.execute(new ClusterBinding(cluster, ReadPreference.nearest()), getOperationContext());
327+
.execute(new ClusterBinding(cluster, ReadPreference.nearest()), createOperationContext());
328328
if (helloResult.containsKey("setName")) {
329329
connectionString = new ConnectionString(DEFAULT_URI + "/?replicaSet="
330330
+ helloResult.getString("setName").getValue());
@@ -384,11 +384,11 @@ public static ReadWriteBinding getBinding(final OperationContext operationContex
384384
}
385385

386386
public static ReadWriteBinding getBinding(final ReadPreference readPreference) {
387-
return getBinding(getCluster(), readPreference, getOperationContext());
387+
return getBinding(getCluster(), readPreference, createOperationContext());
388388
}
389389

390390
public static OperationContext createNewOperationContext(final TimeoutSettings timeoutSettings) {
391-
return getOperationContext().withTimeoutContext(new TimeoutContext(timeoutSettings));
391+
return createOperationContext().withTimeoutContext(new TimeoutContext(timeoutSettings));
392392
}
393393

394394
private static ReadWriteBinding getBinding(final Cluster cluster,
@@ -405,23 +405,23 @@ private static ReadWriteBinding getBinding(final Cluster cluster,
405405
}
406406

407407
public static SingleConnectionBinding getSingleConnectionBinding() {
408-
return new SingleConnectionBinding(getCluster(), ReadPreference.primary(), getOperationContext());
408+
return new SingleConnectionBinding(getCluster(), ReadPreference.primary(), createOperationContext());
409409
}
410410

411411
public static AsyncSingleConnectionBinding getAsyncSingleConnectionBinding() {
412412
return getAsyncSingleConnectionBinding(getAsyncCluster());
413413
}
414414

415415
public static AsyncSingleConnectionBinding getAsyncSingleConnectionBinding(final Cluster cluster) {
416-
return new AsyncSingleConnectionBinding(cluster, ReadPreference.primary(), getOperationContext());
416+
return new AsyncSingleConnectionBinding(cluster, ReadPreference.primary(), createOperationContext());
417417
}
418418

419419
public static AsyncReadWriteBinding getAsyncBinding(final Cluster cluster) {
420420
return new AsyncClusterBinding(cluster, ReadPreference.primary());
421421
}
422422

423423
public static AsyncReadWriteBinding getAsyncBinding() {
424-
return getAsyncBinding(getAsyncCluster(), ReadPreference.primary(), getOperationContext());
424+
return getAsyncBinding(getAsyncCluster(), ReadPreference.primary(), createOperationContext());
425425
}
426426

427427
public static AsyncReadWriteBinding getAsyncBinding(final TimeoutSettings timeoutSettings) {
@@ -433,7 +433,7 @@ public static AsyncReadWriteBinding getAsyncBinding(final OperationContext opera
433433
}
434434

435435
public static AsyncReadWriteBinding getAsyncBinding(final ReadPreference readPreference) {
436-
return getAsyncBinding(getAsyncCluster(), readPreference, getOperationContext());
436+
return getAsyncBinding(getAsyncCluster(), readPreference, createOperationContext());
437437
}
438438

439439
public static AsyncReadWriteBinding getAsyncBinding(
@@ -607,7 +607,7 @@ public static BsonDocument getServerParameters() {
607607
if (serverParameters == null) {
608608
serverParameters = new CommandReadOperation<>("admin",
609609
new BsonDocument("getParameter", new BsonString("*")), new BsonDocumentCodec())
610-
.execute(getBinding(), getOperationContext());
610+
.execute(getBinding(), createOperationContext());
611611
}
612612
return serverParameters;
613613
}
@@ -675,7 +675,7 @@ public static void configureFailPoint(final BsonDocument failPointDocument) {
675675
if (!isSharded()) {
676676
try {
677677
new CommandReadOperation<>("admin", failPointDocument, new BsonDocumentCodec())
678-
.execute(getBinding(), getOperationContext());
678+
.execute(getBinding(), createOperationContext());
679679
} catch (MongoCommandException e) {
680680
if (e.getErrorCode() == COMMAND_NOT_FOUND_ERROR_CODE) {
681681
failsPointsSupported = false;
@@ -691,7 +691,7 @@ public static void disableFailPoint(final String failPoint) {
691691
.append("mode", new BsonString("off"));
692692
try {
693693
new CommandReadOperation<>("admin", failPointDocument, new BsonDocumentCodec())
694-
.execute(getBinding(), getOperationContext());
694+
.execute(getBinding(), createOperationContext());
695695
} catch (MongoCommandException e) {
696696
// ignore
697697
}
@@ -705,7 +705,7 @@ public static <T> T executeSync(final WriteOperation<T> op) {
705705

706706
@SuppressWarnings("overloads")
707707
public static <T> T executeSync(final WriteOperation<T> op, final ReadWriteBinding binding) {
708-
return op.execute(binding, applySessionContext(getOperationContext(), binding.getReadPreference()));
708+
return op.execute(binding, applySessionContext(createOperationContext(), binding.getReadPreference()));
709709
}
710710

711711
@SuppressWarnings("overloads")
@@ -715,7 +715,7 @@ public static <T> T executeSync(final ReadOperation<T, ?> op) {
715715

716716
@SuppressWarnings("overloads")
717717
public static <T> T executeSync(final ReadOperation<T, ?> op, final ReadWriteBinding binding) {
718-
return op.execute(binding, getOperationContext());
718+
return op.execute(binding, createOperationContext());
719719
}
720720

721721
@SuppressWarnings("overloads")
@@ -731,7 +731,7 @@ public static <T> T executeAsync(final WriteOperation<T> op) throws Throwable {
731731
@SuppressWarnings("overloads")
732732
public static <T> T executeAsync(final WriteOperation<T> op, final AsyncReadWriteBinding binding) throws Throwable {
733733
FutureResultCallback<T> futureResultCallback = new FutureResultCallback<>();
734-
op.executeAsync(binding, applySessionContext(getOperationContext(), binding.getReadPreference()), futureResultCallback);
734+
op.executeAsync(binding, applySessionContext(createOperationContext(), binding.getReadPreference()), futureResultCallback);
735735
return futureResultCallback.get(TIMEOUT, SECONDS);
736736
}
737737

@@ -743,7 +743,7 @@ public static <T> T executeAsync(final ReadOperation<?, T> op) throws Throwable
743743
@SuppressWarnings("overloads")
744744
public static <T> T executeAsync(final ReadOperation<?, T> op, final AsyncReadBinding binding) throws Throwable {
745745
FutureResultCallback<T> futureResultCallback = new FutureResultCallback<>();
746-
op.executeAsync(binding, getOperationContext(), futureResultCallback);
746+
op.executeAsync(binding, createOperationContext(), futureResultCallback);
747747
return futureResultCallback.get(TIMEOUT, SECONDS);
748748
}
749749

@@ -813,19 +813,19 @@ public static <T> List<T> collectCursorResults(final BatchCursor<T> batchCursor)
813813

814814
public static AsyncConnectionSource getWriteConnectionSource(final AsyncReadWriteBinding binding) throws Throwable {
815815
FutureResultCallback<AsyncConnectionSource> futureResultCallback = new FutureResultCallback<>();
816-
binding.getWriteConnectionSource(getOperationContext(), futureResultCallback);
816+
binding.getWriteConnectionSource(createOperationContext(), futureResultCallback);
817817
return futureResultCallback.get(TIMEOUT, SECONDS);
818818
}
819819

820820
public static AsyncConnectionSource getReadConnectionSource(final AsyncReadWriteBinding binding) throws Throwable {
821821
FutureResultCallback<AsyncConnectionSource> futureResultCallback = new FutureResultCallback<>();
822-
binding.getReadConnectionSource(getOperationContext(), futureResultCallback);
822+
binding.getReadConnectionSource(createOperationContext(), futureResultCallback);
823823
return futureResultCallback.get(TIMEOUT, SECONDS);
824824
}
825825

826826
public static AsyncConnection getConnection(final AsyncConnectionSource source) throws Throwable {
827827
FutureResultCallback<AsyncConnection> futureResultCallback = new FutureResultCallback<>();
828-
source.getConnection(getOperationContext(), futureResultCallback);
828+
source.getConnection(createOperationContext(), futureResultCallback);
829829
return futureResultCallback.get(TIMEOUT, SECONDS);
830830
}
831831

@@ -868,7 +868,7 @@ private static OperationContext applySessionContext(final OperationContext opera
868868
return operationContext.withSessionContext(simpleSessionContext);
869869
}
870870

871-
public static OperationContext getOperationContext(final ReadPreference readPreference) {
872-
return applySessionContext(getOperationContext(), readPreference);
871+
public static OperationContext createOperationContext(final ReadPreference readPreference) {
872+
return applySessionContext(createOperationContext(), readPreference);
873873
}
874874
}

driver-core/src/test/functional/com/mongodb/OperationFunctionalSpecification.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import spock.lang.Specification
6161

6262
import java.util.concurrent.TimeUnit
6363

64-
import static com.mongodb.ClusterFixture.getOperationContext
64+
import static com.mongodb.ClusterFixture.createOperationContext
6565
import static com.mongodb.ClusterFixture.TIMEOUT
6666
import static com.mongodb.ClusterFixture.checkReferenceCountReachesTarget
6767
import static com.mongodb.ClusterFixture.executeAsync
@@ -108,7 +108,7 @@ class OperationFunctionalSpecification extends Specification {
108108

109109
void acknowledgeWrite(final SingleConnectionBinding binding) {
110110
new MixedBulkWriteOperation(getNamespace(), [new InsertRequest(new BsonDocument())], true,
111-
ACKNOWLEDGED, false).execute(binding, getOperationContext())
111+
ACKNOWLEDGED, false).execute(binding, createOperationContext())
112112
binding.release()
113113
}
114114

@@ -279,7 +279,7 @@ class OperationFunctionalSpecification extends Specification {
279279
BsonDocument expectedCommand=null, Boolean checkSecondaryOk=false,
280280
ReadPreference readPreference=ReadPreference.primary(), Boolean retryable = false,
281281
ServerType serverType = ServerType.STANDALONE, Boolean activeTransaction = false) {
282-
def operationContext = getOperationContext()
282+
def operationContext = createOperationContext()
283283
.withSessionContext(Stub(SessionContext) {
284284
hasActiveTransaction() >> activeTransaction
285285
getReadConcern() >> readConcern
@@ -353,7 +353,7 @@ class OperationFunctionalSpecification extends Specification {
353353
Boolean checkCommand = true, BsonDocument expectedCommand = null, Boolean checkSecondaryOk = false,
354354
ReadPreference readPreference = ReadPreference.primary(), Boolean retryable = false,
355355
ServerType serverType = ServerType.STANDALONE, Boolean activeTransaction = false) {
356-
def operationContext = getOperationContext()
356+
def operationContext = createOperationContext()
357357
.withSessionContext(Stub(SessionContext) {
358358
hasActiveTransaction() >> activeTransaction
359359
getReadConcern() >> readConcern
@@ -447,7 +447,7 @@ class OperationFunctionalSpecification extends Specification {
447447
}
448448
}
449449

450-
def operationContext = getOperationContext().withSessionContext(
450+
def operationContext = createOperationContext().withSessionContext(
451451
Stub(SessionContext) {
452452
hasSession() >> true
453453
hasActiveTransaction() >> false
@@ -488,7 +488,7 @@ class OperationFunctionalSpecification extends Specification {
488488
}
489489
}
490490

491-
def operationContext = getOperationContext().withSessionContext(
491+
def operationContext = createOperationContext().withSessionContext(
492492
Stub(SessionContext) {
493493
hasSession() >> true
494494
hasActiveTransaction() >> false

0 commit comments

Comments
 (0)