Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4f8217a

Browse files
authoredMar 31, 2025
Remove support for MongoDB 4.0 (#1663)
* Remove branching code in the driver based on 4.0 version checks * Remove testing of 4.0 * Clean up tests JAVA-5831
1 parent 6c9c51e commit 4f8217a

27 files changed

+84
-237
lines changed
 

‎.evergreen/.evg.yml

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ functions:
285285
export AWS_TEMP_SESSION_TOKEN=$CSFLE_AWS_TEMP_SESSION_TOKEN
286286
export CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH}
287287
288-
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" \
288+
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" \
289289
COMPRESSOR="${COMPRESSOR}" JAVA_VERSION="${JAVA_VERSION}" REQUIRE_API_VERSION=${REQUIRE_API_VERSION} \
290290
TESTS="${TESTS}" .evergreen/run-tests.sh
291291
@@ -344,7 +344,7 @@ functions:
344344
working_dir: "src"
345345
script: |
346346
${PREPARE_SHELL}
347-
SCALA="${SCALA}" AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-scala-tests.sh
347+
SCALA="${SCALA}" AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-scala-tests.sh
348348
349349
"run kotlin tests":
350350
- command: shell.exec
@@ -353,7 +353,7 @@ functions:
353353
working_dir: "src"
354354
script: |
355355
${PREPARE_SHELL}
356-
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" SAFE_FOR_MULTI_MONGOS="${SAFE_FOR_MULTI_MONGOS}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-kotlin-tests.sh
356+
AUTH="${AUTH}" SSL="${SSL}" MONGODB_URI="${MONGODB_URI}" TOPOLOGY="${TOPOLOGY}" JAVA_VERSION="${JAVA_VERSION}" .evergreen/run-kotlin-tests.sh
357357
358358
359359
"run socket tests":
@@ -599,16 +599,6 @@ functions:
599599
LOGIN_CONTEXT_NAME=${LOGIN_CONTEXT_NAME} \
600600
.evergreen/run-gssapi-auth-test.sh
601601
602-
"run mmapv1 storage test":
603-
- command: shell.exec
604-
type: test
605-
params:
606-
silent: true
607-
working_dir: "src"
608-
script: |
609-
${PREPARE_SHELL}
610-
PROJECT_DIRECTORY=${PROJECT_DIRECTORY} JAVA_VERSION=${JAVA_VERSION} TOPOLOGY=${TOPOLOGY} STORAGE_ENGINE=${STORAGE_ENGINE} MONGODB_URI="${MONGODB_URI}" .evergreen/run-mmapv1-storage-test.sh
611-
612602
run socks5 tests:
613603
- command: shell.exec
614604
type: test
@@ -1577,11 +1567,6 @@ tasks:
15771567
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/driver-lambda/
15781568
AWS_REGION: us-east-1
15791569

1580-
- name: "mmapv1-storage-test"
1581-
commands:
1582-
- func: "bootstrap mongo-orchestration"
1583-
- func: "run mmapv1 storage test"
1584-
15851570
- name: "test-kms-tls-invalid-cert"
15861571
tags: ["kms-tls"]
15871572
commands:
@@ -1717,55 +1702,30 @@ axes:
17171702
display_name: "latest"
17181703
variables:
17191704
VERSION: "latest"
1720-
# Multiple mongos instances can be specified in the connection string
1721-
# for this version.
1722-
SAFE_FOR_MULTI_MONGOS: true
17231705
- id: "8.0"
17241706
display_name: "8.0"
17251707
variables:
17261708
VERSION: "8.0"
1727-
# Multiple mongos instances can be specified in the connection string
1728-
# for this version.
1729-
SAFE_FOR_MULTI_MONGOS: true
17301709
- id: "7.0"
17311710
display_name: "7.0"
17321711
variables:
17331712
VERSION: "7.0"
1734-
# Multiple mongos instances can be specified in the connection string
1735-
# for this version.
1736-
SAFE_FOR_MULTI_MONGOS: true
17371713
- id: "6.0"
17381714
display_name: "6.0"
17391715
variables:
17401716
VERSION: "6.0"
1741-
# Multiple mongos instances can be specified in the connection string
1742-
# for this version.
1743-
SAFE_FOR_MULTI_MONGOS: true
17441717
- id: "5.0"
17451718
display_name: "5.0"
17461719
variables:
17471720
VERSION: "5.0"
1748-
# Multiple mongos instances can be specified in the connection string
1749-
# for this version.
1750-
SAFE_FOR_MULTI_MONGOS: true
17511721
- id: "4.4"
17521722
display_name: "4.4"
17531723
variables:
17541724
VERSION: "4.4"
1755-
# Multiple mongos instances can be specified in the connection string
1756-
# for this version.
1757-
SAFE_FOR_MULTI_MONGOS: true
17581725
- id: "4.2"
17591726
display_name: "4.2"
17601727
variables:
17611728
VERSION: "4.2"
1762-
# Multiple mongos instances can be specified in the connection string
1763-
# for this version.
1764-
SAFE_FOR_MULTI_MONGOS: true
1765-
- id: "4.0"
1766-
display_name: "4.0"
1767-
variables:
1768-
VERSION: "4.0"
17691729
- id: os
17701730
display_name: OS
17711731
values:
@@ -1886,15 +1846,6 @@ axes:
18861846
variables:
18871847
SCALA: "2.13"
18881848

1889-
# Choice of MongoDB storage engine
1890-
- id: storage-engine
1891-
display_name: Storage
1892-
values:
1893-
- id: mmapv1
1894-
display_name: MMAPv1
1895-
variables:
1896-
STORAGE_ENGINE: "mmapv1"
1897-
18981849
- id: api-version
18991850
display_name: API Version
19001851
values:
@@ -2201,7 +2152,7 @@ buildvariants:
22012152
- name: "test-bson-and-crypt"
22022153

22032154
- matrix_name: "tests-jdk8-unsecure"
2204-
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
2155+
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest"],
22052156
topology: "*", os: "linux" }
22062157
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
22072158
tags: ["tests-variant"]
@@ -2213,7 +2164,7 @@ buildvariants:
22132164

22142165
- matrix_name: "tests-jdk-secure"
22152166
matrix_spec: { auth: "auth", ssl: "ssl", jdk: [ "jdk8", "jdk17", "jdk21"],
2216-
version: ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
2167+
version: ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "latest" ],
22172168
topology: "*", os: "linux" }
22182169
display_name: "${version} ${topology} ${auth} ${ssl} ${jdk} ${os} "
22192170
tags: ["tests-variant"]
@@ -2427,12 +2378,6 @@ buildvariants:
24272378
tasks:
24282379
- name: "publish-release"
24292380

2430-
- matrix_name: "tests-storage-engines"
2431-
matrix_spec: { auth: "noauth", ssl: "nossl", jdk: "jdk8", os: "linux", version: ["4.0"], topology: ["replicaset", "sharded-cluster"], storage-engine: "mmapv1" }
2432-
display_name: "${version} Storage ${storage-engine} ${jdk} ${os} ${topology}"
2433-
tasks:
2434-
- name: "mmapv1-storage-test"
2435-
24362381
- matrix_name: "kms-tls-test"
24372382
matrix_spec: { os: "linux", version: [ "5.0" ], topology: ["standalone"] }
24382383
display_name: "CSFLE KMS TLS"

‎.evergreen/run-kotlin-tests.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ AUTH=${AUTH:-noauth}
88
SSL=${SSL:-nossl}
99
MONGODB_URI=${MONGODB_URI:-}
1010
TOPOLOGY=${TOPOLOGY:-standalone}
11-
SAFE_FOR_MULTI_MONGOS=${SAFE_FOR_MULTI_MONGOS:-}
1211

1312
############################################
1413
# Main Program #
@@ -27,9 +26,7 @@ if [ "$AUTH" != "noauth" ]; then
2726
exit 1
2827
fi
2928

30-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
31-
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
32-
fi
29+
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
3330

3431
./gradlew -version
3532

‎.evergreen/run-mmapv1-storage-test.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎.evergreen/run-scala-tests.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ AUTH=${AUTH:-noauth}
88
SSL=${SSL:-nossl}
99
MONGODB_URI=${MONGODB_URI:-}
1010
TOPOLOGY=${TOPOLOGY:-standalone}
11-
SAFE_FOR_MULTI_MONGOS=${SAFE_FOR_MULTI_MONGOS:-}
1211

1312
############################################
1413
# Main Program #
@@ -27,9 +26,7 @@ if [ "$AUTH" != "noauth" ]; then
2726
exit 1
2827
fi
2928

30-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
31-
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
32-
fi
29+
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MONGODB_URI}"
3330

3431
echo "Running scala tests with Scala $SCALA"
3532

‎.evergreen/run-tests.sh

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,10 @@ provision_multi_mongos_uri_for_ssl () {
6868
# Arguments for auth + SSL
6969
if [ "$AUTH" != "noauth" ] || [ "$TOPOLOGY" == "replica_set" ]; then
7070
export MONGODB_URI="${MONGODB_URI}&ssl=true&sslInvalidHostNameAllowed=true"
71-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
72-
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&ssl=true&sslInvalidHostNameAllowed=true"
73-
fi
71+
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&ssl=true&sslInvalidHostNameAllowed=true"
7472
else
7573
export MONGODB_URI="${MONGODB_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
76-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
77-
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
78-
fi
74+
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?ssl=true&sslInvalidHostNameAllowed=true"
7975
fi
8076
}
8177

@@ -85,13 +81,11 @@ provision_multi_mongos_uri_for_ssl () {
8581

8682
# Provision the correct connection string and set up SSL if needed
8783
if [ "$TOPOLOGY" == "sharded_cluster" ]; then
88-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
89-
if [ "$AUTH" = "auth" ]; then
90-
export MULTI_MONGOS_URI="mongodb://bob:pwd123@localhost:27017,localhost:27018/?authSource=admin"
91-
else
92-
export MULTI_MONGOS_URI="${MONGODB_URI}"
93-
fi
94-
fi
84+
if [ "$AUTH" = "auth" ]; then
85+
export MULTI_MONGOS_URI="mongodb://bob:pwd123@localhost:27017,localhost:27018/?authSource=admin"
86+
else
87+
export MULTI_MONGOS_URI="${MONGODB_URI}"
88+
fi
9589

9690
if [ "$AUTH" = "auth" ]; then
9791
export MONGODB_URI="mongodb://bob:pwd123@localhost:27017/?authSource=admin"
@@ -107,12 +101,10 @@ if [ "$COMPRESSOR" != "" ]; then
107101
export MONGODB_URI="${MONGODB_URI}/?compressors=${COMPRESSOR}"
108102
fi
109103

110-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
111-
if [[ "$MULTI_MONGOS_URI" == *"?"* ]]; then
112-
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&compressors=${COMPRESSOR}"
113-
else
114-
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?compressors=${COMPRESSOR}"
115-
fi
104+
if [[ "$MULTI_MONGOS_URI" == *"?"* ]]; then
105+
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}&compressors=${COMPRESSOR}"
106+
else
107+
export MULTI_MONGOS_URI="${MULTI_MONGOS_URI}/?compressors=${COMPRESSOR}"
116108
fi
117109
fi
118110

@@ -123,9 +115,7 @@ if [ "$SSL" != "nossl" ]; then
123115
provision_multi_mongos_uri_for_ssl
124116
fi
125117

126-
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then
127-
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MULTI_MONGOS_URI}"
128-
fi
118+
export MULTI_MONGOS_URI_SYSTEM_PROPERTY="-Dorg.mongodb.test.multi.mongos.uri=${MULTI_MONGOS_URI}"
129119

130120
# For now it's sufficient to hard-code the API version to "1", since it's the only API version
131121
if [ ! -z "$REQUIRE_API_VERSION" ]; then

‎driver-core/src/main/com/mongodb/connection/ConnectionDescription.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import static com.mongodb.assertions.Assertions.notNull;
3131
import static com.mongodb.connection.ServerDescription.getDefaultMaxDocumentSize;
32+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;
3233

3334
/**
3435
* A description of a connection to a MongoDB server.
@@ -57,7 +58,7 @@ public class ConnectionDescription {
5758
* @param serverId the server address
5859
*/
5960
public ConnectionDescription(final ServerId serverId) {
60-
this(new ConnectionId(serverId), 0, ServerType.UNKNOWN, DEFAULT_MAX_WRITE_BATCH_SIZE,
61+
this(new ConnectionId(serverId), UNKNOWN_WIRE_VERSION, ServerType.UNKNOWN, DEFAULT_MAX_WRITE_BATCH_SIZE,
6162
getDefaultMaxDocumentSize(), DEFAULT_MAX_MESSAGE_SIZE, Collections.emptyList());
6263
}
6364

‎driver-core/src/main/com/mongodb/connection/ServerDescription.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public class ServerDescription {
5555
* The minimum supported driver server version
5656
* @since 3.8
5757
*/
58-
public static final String MIN_DRIVER_SERVER_VERSION = "3.6";
58+
public static final String MIN_DRIVER_SERVER_VERSION = "4.2";
5959
/**
6060
* The minimum supported driver wire version
6161
* @since 3.8
6262
*/
63-
public static final int MIN_DRIVER_WIRE_VERSION = 7;
63+
public static final int MIN_DRIVER_WIRE_VERSION = 8;
6464
/**
6565
* The maximum supported driver wire version
6666
* @since 3.8

‎driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
import static com.mongodb.internal.connection.ByteBufBsonDocument.createList;
6161
import static com.mongodb.internal.connection.ByteBufBsonDocument.createOne;
6262
import static com.mongodb.internal.connection.ReadConcernHelper.getReadConcernDocument;
63-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_TWO_WIRE_VERSION;
64-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION;
63+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;
6564

6665
/**
6766
* A command message that uses OP_MSG or OP_QUERY to send the command.
@@ -346,7 +345,6 @@ private List<BsonElement> getExtraElements(final OperationContext operationConte
346345

347346
assertFalse(sessionContext.hasActiveTransaction() && sessionContext.isSnapshot());
348347
if (sessionContext.hasActiveTransaction()) {
349-
checkServerVersionForTransactionSupport();
350348
extraElements.add(new BsonElement("txnNumber", new BsonInt64(sessionContext.getTransactionNumber())));
351349
if (firstMessageInTransaction) {
352350
extraElements.add(new BsonElement("startTransaction", BsonBoolean.TRUE));
@@ -381,12 +379,6 @@ private void addServerApiElements(final List<BsonElement> extraElements) {
381379
}
382380
}
383381

384-
private void checkServerVersionForTransactionSupport() {
385-
if (getSettings().getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION && getSettings().getServerType() == SHARD_ROUTER) {
386-
throw new MongoClientException("Transactions are not supported by the MongoDB cluster to which this client is connected.");
387-
}
388-
}
389-
390382

391383
private void addReadConcernDocument(final List<BsonElement> extraElements, final SessionContext sessionContext) {
392384
BsonDocument readConcernDocument = getReadConcernDocument(sessionContext, getSettings().getMaxWireVersion());
@@ -416,7 +408,7 @@ private static OpCode getOpCode(final MessageSettings settings, final ClusterCon
416408
}
417409

418410
private static boolean isServerVersionKnown(final MessageSettings settings) {
419-
return settings.getMaxWireVersion() >= FOUR_DOT_ZERO_WIRE_VERSION;
411+
return settings.getMaxWireVersion() != UNKNOWN_WIRE_VERSION;
420412
}
421413

422414
@FunctionalInterface

‎driver-core/src/main/com/mongodb/internal/connection/DefaultSdamServerDescriptionManager.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
119119
}
120120
if (sdamIssue.relatedToStateChange()) {
121121
updateDescription(sdamIssue.serverDescription());
122-
if (sdamIssue.serverIsLessThanVersionFourDotTwo() || sdamIssue.relatedToShutdown()) {
122+
if (sdamIssue.relatedToShutdown()) {
123123
connectionPool.invalidate(sdamIssue.exception().orElse(null));
124124
}
125125
serverMonitor.connect();
@@ -130,9 +130,6 @@ private void handleException(final SdamIssue sdamIssue, final boolean beforeHand
130130
serverMonitor.cancelCurrentCheck();
131131
} else if (sdamIssue.relatedToWriteConcern() || !sdamIssue.specific()) {
132132
updateDescription(sdamIssue.serverDescription());
133-
if (sdamIssue.serverIsLessThanVersionFourDotTwo()) {
134-
connectionPool.invalidate(sdamIssue.exception().orElse(null));
135-
}
136133
serverMonitor.connect();
137134
}
138135
}

‎driver-core/src/main/com/mongodb/internal/connection/MessageSettings.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.mongodb.annotations.NotThreadSafe;
2121
import com.mongodb.connection.ServerType;
2222

23+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;
24+
2325
/**
2426
* The message settings
2527
*
@@ -75,7 +77,7 @@ public static final class Builder {
7577
private int maxDocumentSize = DEFAULT_MAX_DOCUMENT_SIZE;
7678
private int maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE;
7779
private int maxBatchCount = DEFAULT_MAX_BATCH_COUNT;
78-
private int maxWireVersion;
80+
private int maxWireVersion = UNKNOWN_WIRE_VERSION;
7981
private ServerType serverType;
8082
private boolean sessionSupported;
8183
private boolean cryptd;

‎driver-core/src/main/com/mongodb/internal/connection/SdamServerDescriptionManager.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import static com.mongodb.assertions.Assertions.assertTrue;
3636
import static com.mongodb.internal.connection.ClusterableServer.SHUTDOWN_CODES;
3737
import static com.mongodb.internal.connection.ServerDescriptionHelper.unknownConnectingServerDescription;
38-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_TWO_WIRE_VERSION;
3938

4039
/**
4140
* See the
@@ -117,10 +116,6 @@ ServerDescription serverDescription() {
117116
return unknownConnectingServerDescription(context.serverId(), exception);
118117
}
119118

120-
boolean serverIsLessThanVersionFourDotTwo() {
121-
return context.serverIsLessThanVersionFourDotTwo();
122-
}
123-
124119
boolean stale(final ConnectionPool connectionPool, final ServerDescription currentServerDescription) {
125120
return context.stale(connectionPool) || stale(exception, currentServerDescription);
126121
}
@@ -192,10 +187,6 @@ static final class Context {
192187
this.serverMaxWireVersion = serverMaxWireVersion;
193188
}
194189

195-
private boolean serverIsLessThanVersionFourDotTwo() {
196-
return serverMaxWireVersion < FOUR_DOT_TWO_WIRE_VERSION;
197-
}
198-
199190
private boolean stale(final ConnectionPool connectionPool) {
200191
return connectionPoolGeneration < connectionPool.getGeneration();
201192
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import static com.mongodb.internal.connection.CommandHelper.applyMaxTimeMS;
3636
import static com.mongodb.internal.operation.ExplainHelper.asExplainCommand;
37-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION;
37+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;
3838

3939
/**
4040
* An operation that executes an aggregation query.
@@ -157,7 +157,7 @@ public <R> AsyncReadOperation<R> asAsyncExplainableOperation(@Nullable final Exp
157157
<R> CommandReadOperation<R> createExplainableOperation(@Nullable final ExplainVerbosity verbosity, final Decoder<R> resultDecoder) {
158158
return new CommandReadOperation<>(getNamespace().getDatabaseName(),
159159
(operationContext, serverDescription, connectionDescription) -> {
160-
BsonDocument command = wrapped.getCommand(operationContext, MIN_WIRE_VERSION);
160+
BsonDocument command = wrapped.getCommand(operationContext, UNKNOWN_WIRE_VERSION);
161161
applyMaxTimeMS(operationContext.getTimeoutContext(), command);
162162
return asExplainCommand(command, verbosity);
163163
}, resultDecoder);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import static com.mongodb.internal.operation.OperationHelper.canRetryRead;
5757
import static com.mongodb.internal.operation.OperationHelper.setNonTailableCursorMaxTimeSupplier;
5858
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand;
59-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION;
59+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION;
6060
import static com.mongodb.internal.operation.SyncOperationHelper.CommandReadTransformer;
6161
import static com.mongodb.internal.operation.SyncOperationHelper.createReadCommandAndExecute;
6262
import static com.mongodb.internal.operation.SyncOperationHelper.decorateReadWithRetries;
@@ -366,7 +366,7 @@ public <R> AsyncReadOperation<R> asAsyncExplainableOperation(@Nullable final Exp
366366
<R> CommandReadOperation<R> createExplainableOperation(@Nullable final ExplainVerbosity verbosity, final Decoder<R> resultDecoder) {
367367
return new CommandReadOperation<>(getNamespace().getDatabaseName(),
368368
(operationContext, serverDescription, connectionDescription) -> {
369-
BsonDocument command = getCommand(operationContext, MIN_WIRE_VERSION);
369+
BsonDocument command = getCommand(operationContext, UNKNOWN_WIRE_VERSION);
370370
applyMaxTimeMS(operationContext.getTimeoutContext(), command);
371371
return asExplainCommand(command, verbosity);
372372
}, resultDecoder);

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
import static com.mongodb.assertions.Assertions.assertNotNull;
4848
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotFour;
49-
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotTwo;
5049
import static java.lang.String.format;
5150

5251
/**
@@ -70,10 +69,6 @@ private static void validateArrayFilters(final WriteConcern writeConcern) {
7069
private static void validateWriteRequestHint(final ConnectionDescription connectionDescription, final WriteConcern writeConcern,
7170
final WriteRequest request) {
7271
if (!writeConcern.isAcknowledged()) {
73-
if (request instanceof UpdateRequest && serverIsLessThanVersionFourDotTwo(connectionDescription)) {
74-
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
75-
connectionDescription.getMaxWireVersion()));
76-
}
7772
if (request instanceof DeleteRequest && serverIsLessThanVersionFourDotFour(connectionDescription)) {
7873
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
7974
connectionDescription.getMaxWireVersion()));
@@ -82,10 +77,6 @@ private static void validateWriteRequestHint(final ConnectionDescription connect
8277
}
8378

8479
static void validateHintForFindAndModify(final ConnectionDescription connectionDescription, final WriteConcern writeConcern) {
85-
if (serverIsLessThanVersionFourDotTwo(connectionDescription)) {
86-
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
87-
connectionDescription.getMaxWireVersion()));
88-
}
8980
if (!writeConcern.isAcknowledged() && serverIsLessThanVersionFourDotFour(connectionDescription)) {
9081
throw new IllegalArgumentException(format("Hint not supported by wire version: %s",
9182
connectionDescription.getMaxWireVersion()));

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,19 @@
2424
*/
2525
public final class ServerVersionHelper {
2626

27-
public static final int MIN_WIRE_VERSION = 0;
28-
public static final int FOUR_DOT_ZERO_WIRE_VERSION = 7;
27+
public static final int UNKNOWN_WIRE_VERSION = 0;
2928
public static final int FOUR_DOT_TWO_WIRE_VERSION = 8;
3029
public static final int FOUR_DOT_FOUR_WIRE_VERSION = 9;
31-
public static final int FIVE_DOT_ZERO_WIRE_VERSION = 12;
30+
public static final int FIVE_DOT_ZERO_WIRE_VERSION = 13;
3231
public static final int SIX_DOT_ZERO_WIRE_VERSION = 17;
3332
public static final int SEVEN_DOT_ZERO_WIRE_VERSION = 21;
34-
public static final int LATEST_WIRE_VERSION = SEVEN_DOT_ZERO_WIRE_VERSION;
33+
public static final int EIGHT_DOT_ZERO_WIRE_VERSION = 25;
34+
public static final int LATEST_WIRE_VERSION = EIGHT_DOT_ZERO_WIRE_VERSION;
3535

3636
public static boolean serverIsAtLeastVersionFourDotFour(final ConnectionDescription description) {
3737
return description.getMaxWireVersion() >= FOUR_DOT_FOUR_WIRE_VERSION;
3838
}
3939

40-
public static boolean serverIsLessThanVersionFourDotTwo(final ConnectionDescription description) {
41-
return description.getMaxWireVersion() < FOUR_DOT_TWO_WIRE_VERSION;
42-
}
43-
4440
public static boolean serverIsLessThanVersionFourDotFour(final ConnectionDescription description) {
4541
return description.getMaxWireVersion() < FOUR_DOT_FOUR_WIRE_VERSION;
4642
}

‎driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import static com.mongodb.ExplainVerbosity.QUERY_PLANNER
6565
import static com.mongodb.connection.ServerType.STANDALONE
6666
import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease
6767
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
68-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
68+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
6969

7070
class AggregateOperationSpecification extends OperationFunctionalSpecification {
7171

@@ -386,7 +386,7 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
386386
def commandDocument = new BsonDocument('aggregate', new BsonString(getCollectionName()))
387387
.append('pipeline', new BsonArray())
388388
.append('cursor', new BsonDocument())
389-
appendReadConcernToCommand(operationContext.getSessionContext(), MIN_WIRE_VERSION, commandDocument)
389+
appendReadConcernToCommand(operationContext.getSessionContext(), UNKNOWN_WIRE_VERSION, commandDocument)
390390

391391
def operation = new AggregateOperation<Document>(getNamespace(), [], new DocumentCodec())
392392

@@ -427,7 +427,7 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
427427
def commandDocument = new BsonDocument('aggregate', new BsonString(getCollectionName()))
428428
.append('pipeline', new BsonArray())
429429
.append('cursor', new BsonDocument())
430-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
430+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
431431

432432
def operation = new AggregateOperation<Document>(getNamespace(), [], new DocumentCodec())
433433

‎driver-core/src/test/functional/com/mongodb/internal/operation/CountDocumentsOperationSpecification.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import static com.mongodb.ClusterFixture.getBinding
5050
import static com.mongodb.ClusterFixture.serverVersionAtLeast
5151
import static com.mongodb.connection.ServerType.STANDALONE
5252
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
53-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
53+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
5454

5555
class CountDocumentsOperationSpecification extends OperationFunctionalSpecification {
5656

@@ -274,7 +274,7 @@ class CountDocumentsOperationSpecification extends OperationFunctionalSpecificat
274274
def commandDocument = new BsonDocument('aggregate', new BsonString(getCollectionName()))
275275
.append('pipeline', pipeline)
276276
.append('cursor', new BsonDocument())
277-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
277+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
278278

279279
def operation = new CountDocumentsOperation(getNamespace())
280280

@@ -314,7 +314,7 @@ class CountDocumentsOperationSpecification extends OperationFunctionalSpecificat
314314
def commandDocument = new BsonDocument('aggregate', new BsonString(getCollectionName()))
315315
.append('pipeline', pipeline)
316316
.append('cursor', new BsonDocument())
317-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
317+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
318318

319319
def operation = new CountDocumentsOperation(getNamespace())
320320

‎driver-core/src/test/functional/com/mongodb/internal/operation/DistinctOperationSpecification.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import static com.mongodb.ClusterFixture.executeAsync
5656
import static com.mongodb.ClusterFixture.serverVersionLessThan
5757
import static com.mongodb.connection.ServerType.STANDALONE
5858
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
59-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
59+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
6060
import static org.bson.codecs.configuration.CodecRegistries.fromProviders
6161

6262
class DistinctOperationSpecification extends OperationFunctionalSpecification {
@@ -240,7 +240,7 @@ class DistinctOperationSpecification extends OperationFunctionalSpecification {
240240
source.operationContext >> operationContext
241241
def commandDocument = new BsonDocument('distinct', new BsonString(getCollectionName()))
242242
.append('key', new BsonString('str'))
243-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
243+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
244244

245245
def operation = new DistinctOperation<String>(getNamespace(), 'str', new StringCodec())
246246

@@ -279,7 +279,7 @@ class DistinctOperationSpecification extends OperationFunctionalSpecification {
279279
source.retain() >> source
280280
def commandDocument = new BsonDocument('distinct', new BsonString(getCollectionName()))
281281
.append('key', new BsonString('str'))
282-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
282+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
283283

284284
def operation = new DistinctOperation<String>(getNamespace(), 'str', new StringCodec())
285285

‎driver-core/src/test/functional/com/mongodb/internal/operation/FindOperationSpecification.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ import static com.mongodb.CursorType.Tailable
6767
import static com.mongodb.CursorType.TailableAwait
6868
import static com.mongodb.connection.ServerType.STANDALONE
6969
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
70-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
70+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
7171
import static org.junit.Assert.assertEquals
7272

7373
class FindOperationSpecification extends OperationFunctionalSpecification {
@@ -498,7 +498,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
498498
source.retain() >> source
499499
source.operationContext >> operationContext
500500
def commandDocument = new BsonDocument('find', new BsonString(getCollectionName()))
501-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
501+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
502502

503503
def operation = new FindOperation<Document>(getNamespace(), new DocumentCodec())
504504

@@ -538,7 +538,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
538538
source.getConnection(_) >> { it[0].onResult(connection, null) }
539539
source.retain() >> source
540540
def commandDocument = new BsonDocument('find', new BsonString(getCollectionName()))
541-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
541+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
542542

543543
def operation = new FindOperation<Document>(getNamespace(), new DocumentCodec())
544544

@@ -579,7 +579,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
579579
source.retain() >> source
580580
source.operationContext >> operationContext
581581
def commandDocument = new BsonDocument('find', new BsonString(getCollectionName())).append('allowDiskUse', BsonBoolean.TRUE)
582-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
582+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
583583

584584
def operation = new FindOperation<Document>(getNamespace(), new DocumentCodec()).allowDiskUse(true)
585585

@@ -619,7 +619,7 @@ class FindOperationSpecification extends OperationFunctionalSpecification {
619619
source.getConnection(_) >> { it[0].onResult(connection, null) }
620620
source.retain() >> source
621621
def commandDocument = new BsonDocument('find', new BsonString(getCollectionName())).append('allowDiskUse', BsonBoolean.TRUE)
622-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
622+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
623623

624624
def operation = new FindOperation<Document>(getNamespace(), new DocumentCodec()).allowDiskUse(true)
625625

‎driver-core/src/test/functional/com/mongodb/internal/operation/MapReduceWithInlineResultsOperationSpecification.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import static com.mongodb.ClusterFixture.executeAsync
5050
import static com.mongodb.ClusterFixture.serverVersionLessThan
5151
import static com.mongodb.connection.ServerType.STANDALONE
5252
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
53-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
53+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
5454

5555
class MapReduceWithInlineResultsOperationSpecification extends OperationFunctionalSpecification {
5656
private final bsonDocumentCodec = new BsonDocumentCodec()
@@ -234,7 +234,7 @@ class MapReduceWithInlineResultsOperationSpecification extends OperationFunction
234234
"reduce" : { "$code" : "function(key, values){ }" },
235235
"out" : { "inline" : 1 },
236236
}''')
237-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
237+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
238238

239239
def operation = new MapReduceWithInlineResultsOperation<BsonDocument>(helper.namespace,
240240
new BsonJavaScript('function(){ }'), new BsonJavaScript('function(key, values){ }'), bsonDocumentCodec)
@@ -283,7 +283,7 @@ class MapReduceWithInlineResultsOperationSpecification extends OperationFunction
283283
"reduce" : { "$code" : "function(key, values){ }" },
284284
"out" : { "inline" : 1 },
285285
}''')
286-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
286+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
287287

288288
def operation = new MapReduceWithInlineResultsOperation<BsonDocument>(helper.namespace,
289289
new BsonJavaScript('function(){ }'), new BsonJavaScript('function(key, values){ }'), bsonDocumentCodec)

‎driver-core/src/test/functional/com/mongodb/internal/operation/OperationReadConcernHelperSpecification.groovy

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ import org.bson.BsonTimestamp
2424
import spock.lang.Specification
2525

2626
import static com.mongodb.internal.operation.OperationReadConcernHelper.appendReadConcernToCommand
27-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
27+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
2828

2929

3030
class OperationReadConcernHelperSpecification extends Specification {
3131

3232
def 'should throw IllegalArgumentException if command document is null'() {
3333
when:
34-
appendReadConcernToCommand(Stub(SessionContext), MIN_WIRE_VERSION, null)
34+
appendReadConcernToCommand(Stub(SessionContext), UNKNOWN_WIRE_VERSION, null)
3535

3636
then:
3737
thrown(IllegalArgumentException)
3838
}
3939

4040
def 'should throw IllegalArgumentException if session context is null'() {
4141
when:
42-
appendReadConcernToCommand(null, MIN_WIRE_VERSION, new BsonDocument())
42+
appendReadConcernToCommand(null, UNKNOWN_WIRE_VERSION, new BsonDocument())
4343

4444
then:
4545
thrown(IllegalArgumentException)
@@ -56,7 +56,7 @@ class OperationReadConcernHelperSpecification extends Specification {
5656
def commandDocument = new BsonDocument()
5757

5858
when:
59-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
59+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
6060

6161
then:
6262
commandDocument == new BsonDocument('readConcern',
@@ -74,7 +74,7 @@ class OperationReadConcernHelperSpecification extends Specification {
7474
def commandDocument = new BsonDocument()
7575

7676
when:
77-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
77+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
7878

7979
then:
8080
commandDocument == new BsonDocument('readConcern',
@@ -91,7 +91,7 @@ class OperationReadConcernHelperSpecification extends Specification {
9191
def commandDocument = new BsonDocument()
9292

9393
when:
94-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
94+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
9595

9696
then:
9797
commandDocument == new BsonDocument('readConcern',
@@ -107,7 +107,7 @@ class OperationReadConcernHelperSpecification extends Specification {
107107
def commandDocument = new BsonDocument()
108108

109109
when:
110-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
110+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
111111

112112
then:
113113
commandDocument == new BsonDocument()
@@ -123,7 +123,7 @@ class OperationReadConcernHelperSpecification extends Specification {
123123
def commandDocument = new BsonDocument()
124124

125125
when:
126-
appendReadConcernToCommand(sessionContext, MIN_WIRE_VERSION, commandDocument)
126+
appendReadConcernToCommand(sessionContext, UNKNOWN_WIRE_VERSION, commandDocument)
127127

128128
then:
129129
commandDocument == new BsonDocument('readConcern',

‎driver-core/src/test/unit/com/mongodb/internal/connection/CommandMessageSpecification.groovy

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.mongodb.internal.connection
1818

19-
import com.mongodb.MongoClientException
19+
2020
import com.mongodb.MongoNamespace
2121
import com.mongodb.ReadConcern
2222
import com.mongodb.ReadPreference
@@ -43,7 +43,6 @@ import spock.lang.Specification
4343
import java.nio.ByteBuffer
4444

4545
import static com.mongodb.internal.connection.SplittablePayload.Type.INSERT
46-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION
4746
import static com.mongodb.internal.operation.ServerVersionHelper.LATEST_WIRE_VERSION
4847

4948
/**
@@ -360,30 +359,6 @@ class CommandMessageSpecification extends Specification {
360359
output.close()
361360
}
362361

363-
def 'should throw if wire version and sharded cluster does not support transactions'() {
364-
given:
365-
def messageSettings = MessageSettings.builder().serverType(ServerType.SHARD_ROUTER)
366-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION).build()
367-
def payload = new SplittablePayload(INSERT, [new BsonDocument('a', new BsonInt32(1))], true, fieldNameValidator)
368-
def message = new CommandMessage(namespace, command, fieldNameValidator, ReadPreference.primary(), messageSettings,
369-
false, payload, ClusterConnectionMode.MULTIPLE, null)
370-
def output = new ByteBufferBsonOutput(new SimpleBufferProvider())
371-
def sessionContext = Stub(SessionContext) {
372-
getReadConcern() >> ReadConcern.DEFAULT
373-
hasActiveTransaction() >> true
374-
}
375-
376-
when:
377-
message.encode(output, new OperationContext(IgnorableRequestContext.INSTANCE, sessionContext,
378-
Stub(TimeoutContext), null))
379-
380-
then:
381-
thrown(MongoClientException)
382-
383-
cleanup:
384-
output.close()
385-
}
386-
387362
private static BsonDocument getCommandDocument(ByteBufNIO byteBuf, ReplyHeader replyHeader) {
388363
new ReplyMessage<BsonDocument>(new ResponseBuffers(replyHeader, byteBuf), new BsonDocumentCodec(), 0).document
389364
}

‎driver-core/src/test/unit/com/mongodb/internal/connection/CommandMessageTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import static com.mongodb.MongoClientSettings.getDefaultCodecRegistry;
4949
import static com.mongodb.client.model.bulk.ClientBulkWriteOptions.clientBulkWriteOptions;
5050
import static com.mongodb.internal.mockito.MongoMockito.mock;
51-
import static com.mongodb.internal.operation.ServerVersionHelper.FOUR_DOT_ZERO_WIRE_VERSION;
5251
import static com.mongodb.internal.operation.ServerVersionHelper.LATEST_WIRE_VERSION;
5352
import static java.util.Arrays.asList;
5453
import static java.util.Collections.singletonList;
@@ -69,7 +68,7 @@ void encodeShouldThrowTimeoutExceptionWhenTimeoutContextIsCalled() {
6968
//given
7069
CommandMessage commandMessage = new CommandMessage(NAMESPACE, COMMAND, NoOpFieldNameValidator.INSTANCE, ReadPreference.primary(),
7170
MessageSettings.builder()
72-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION)
71+
.maxWireVersion(LATEST_WIRE_VERSION)
7372
.serverType(ServerType.REPLICA_SET_SECONDARY)
7473
.sessionSupported(true)
7574
.build(),
@@ -96,7 +95,7 @@ void encodeShouldNotAddExtraElementsFromTimeoutContextWhenConnectedToMongoCrypt(
9695
//given
9796
CommandMessage commandMessage = new CommandMessage(NAMESPACE, COMMAND, NoOpFieldNameValidator.INSTANCE, ReadPreference.primary(),
9897
MessageSettings.builder()
99-
.maxWireVersion(FOUR_DOT_ZERO_WIRE_VERSION)
98+
.maxWireVersion(LATEST_WIRE_VERSION)
10099
.serverType(ServerType.REPLICA_SET_SECONDARY)
101100
.sessionSupported(true)
102101
.cryptd(true)

‎driver-core/src/test/unit/com/mongodb/internal/connection/ReadConcernHelperSpecification.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import org.bson.BsonTimestamp
2424
import spock.lang.Specification
2525

2626
import static com.mongodb.internal.connection.ReadConcernHelper.getReadConcernDocument
27-
import static com.mongodb.internal.operation.ServerVersionHelper.MIN_WIRE_VERSION
27+
import static com.mongodb.internal.operation.ServerVersionHelper.UNKNOWN_WIRE_VERSION
2828

2929
class ReadConcernHelperSpecification extends Specification {
3030

3131
def 'should throw IllegalArgumentException if session context is null'() {
3232
when:
33-
getReadConcernDocument(null, MIN_WIRE_VERSION)
33+
getReadConcernDocument(null, UNKNOWN_WIRE_VERSION)
3434

3535
then:
3636
thrown(IllegalArgumentException)
@@ -46,7 +46,7 @@ class ReadConcernHelperSpecification extends Specification {
4646
}
4747

4848
expect:
49-
getReadConcernDocument(sessionContext, MIN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
49+
getReadConcernDocument(sessionContext, UNKNOWN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
5050
.append('afterClusterTime', operationTime)
5151
}
5252

@@ -60,7 +60,8 @@ class ReadConcernHelperSpecification extends Specification {
6060
}
6161

6262
expect:
63-
getReadConcernDocument(sessionContext, MIN_WIRE_VERSION) == new BsonDocument(new BsonDocument('afterClusterTime', operationTime))
63+
getReadConcernDocument(sessionContext, UNKNOWN_WIRE_VERSION) ==
64+
new BsonDocument(new BsonDocument('afterClusterTime', operationTime))
6465
}
6566

6667
def 'should not add afterClusterTime to ReadConcern when session is not causally consistent'() {
@@ -72,7 +73,7 @@ class ReadConcernHelperSpecification extends Specification {
7273
}
7374

7475
expect:
75-
getReadConcernDocument(sessionContext, MIN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
76+
getReadConcernDocument(sessionContext, UNKNOWN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
7677
}
7778

7879
def 'should not add afterClusterTime to ReadConcern when operation time is null'() {
@@ -84,6 +85,6 @@ class ReadConcernHelperSpecification extends Specification {
8485
}
8586

8687
expect:
87-
getReadConcernDocument(sessionContext, MIN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
88+
getReadConcernDocument(sessionContext, UNKNOWN_WIRE_VERSION) == new BsonDocument('level', new BsonString('majority'))
8889
}
8990
}

‎driver-core/src/test/unit/com/mongodb/internal/connection/ServerDiscoveryAndMonitoringTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.bson.BsonDocument;
2424
import org.bson.BsonNull;
2525
import org.bson.BsonValue;
26+
import org.junit.Before;
2627
import org.junit.Test;
2728
import org.junit.runner.RunWith;
2829
import org.junit.runners.Parameterized;
@@ -39,16 +40,25 @@
3940
import static org.junit.Assert.assertNull;
4041
import static org.junit.Assert.assertTrue;
4142
import static org.junit.Assert.fail;
43+
import static org.junit.Assume.assumeFalse;
4244

4345
// See https://github.com/mongodb/specifications/tree/master/source/server-discovery-and-monitoring/tests
4446
@RunWith(Parameterized.class)
4547
public class ServerDiscoveryAndMonitoringTest extends AbstractServerDiscoveryAndMonitoringTest {
4648

49+
private final String description;
50+
4751
public ServerDiscoveryAndMonitoringTest(final String description, final BsonDocument definition) {
4852
super(definition);
53+
this.description = description;
4954
init(serverAddress -> NO_OP_SERVER_LISTENER, NO_OP_CLUSTER_LISTENER);
5055
}
5156

57+
@Before
58+
public void setUp() {
59+
assumeFalse(description.startsWith("pre-42"));
60+
}
61+
5262
@Test
5363
public void shouldPassAllOutcomes() {
5464
for (BsonValue phase : getDefinition().getArray("phases")) {

‎driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/CryptConnection.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
package com.mongodb.reactivestreams.client.internal.crypt;
1818

19-
import com.mongodb.MongoClientException;
2019
import com.mongodb.ReadPreference;
2120
import com.mongodb.connection.ConnectionDescription;
2221
import com.mongodb.internal.async.SingleResultCallback;
2322
import com.mongodb.internal.connection.AsyncConnection;
2423
import com.mongodb.internal.connection.Connection;
25-
import com.mongodb.internal.connection.MessageSettings;
2624
import com.mongodb.internal.connection.MessageSequences;
2725
import com.mongodb.internal.connection.MessageSequences.EmptyMessageSequences;
26+
import com.mongodb.internal.connection.MessageSettings;
2827
import com.mongodb.internal.connection.OperationContext;
2928
import com.mongodb.internal.connection.SplittablePayload;
3029
import com.mongodb.internal.connection.SplittablePayloadBsonWriter;
@@ -54,7 +53,6 @@
5453
import java.util.function.Function;
5554

5655
import static com.mongodb.assertions.Assertions.fail;
57-
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotTwo;
5856
import static com.mongodb.reactivestreams.client.internal.MongoOperationPublisher.sinkToCallback;
5957
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
6058

@@ -105,11 +103,6 @@ public <T> void commandAsync(final String database, final BsonDocument command,
105103
final OperationContext operationContext, final boolean responseExpected, final MessageSequences sequences,
106104
final SingleResultCallback<T> callback) {
107105

108-
if (serverIsLessThanVersionFourDotTwo(wrapped.getDescription())) {
109-
callback.onResult(null, new MongoClientException("Auto-encryption requires a minimum MongoDB version of 4.2"));
110-
return;
111-
}
112-
113106
try {
114107
SplittablePayload payload = null;
115108
FieldNameValidator payloadFieldNameValidator = null;

‎driver-sync/src/main/com/mongodb/client/internal/CryptConnection.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
package com.mongodb.client.internal;
1818

19-
import com.mongodb.MongoClientException;
2019
import com.mongodb.ReadPreference;
2120
import com.mongodb.connection.ConnectionDescription;
2221
import com.mongodb.internal.connection.Connection;
23-
import com.mongodb.internal.connection.MessageSettings;
2422
import com.mongodb.internal.connection.MessageSequences;
2523
import com.mongodb.internal.connection.MessageSequences.EmptyMessageSequences;
24+
import com.mongodb.internal.connection.MessageSettings;
2625
import com.mongodb.internal.connection.OperationContext;
2726
import com.mongodb.internal.connection.SplittablePayload;
2827
import com.mongodb.internal.connection.SplittablePayloadBsonWriter;
@@ -50,7 +49,6 @@
5049
import java.util.Map;
5150

5251
import static com.mongodb.assertions.Assertions.fail;
53-
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsLessThanVersionFourDotTwo;
5452
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
5553

5654
/**
@@ -95,10 +93,6 @@ public <T> T command(final String database, final BsonDocument command, final Fi
9593
@Nullable final ReadPreference readPreference, final Decoder<T> commandResultDecoder,
9694
final OperationContext operationContext, final boolean responseExpected, final MessageSequences sequences) {
9795

98-
if (serverIsLessThanVersionFourDotTwo(wrapped.getDescription())) {
99-
throw new MongoClientException("Auto-encryption requires a minimum MongoDB version of 4.2");
100-
}
101-
10296
SplittablePayload payload = null;
10397
FieldNameValidator payloadFieldNameValidator = null;
10498
if (sequences instanceof SplittablePayload) {

0 commit comments

Comments
 (0)
Please sign in to comment.