diff --git a/driver-core/src/main/com/mongodb/TransactionOptions.java b/driver-core/src/main/com/mongodb/TransactionOptions.java
index e4cafe9161c..540ad2c04e7 100644
--- a/driver-core/src/main/com/mongodb/TransactionOptions.java
+++ b/driver-core/src/main/com/mongodb/TransactionOptions.java
@@ -219,7 +219,20 @@ public Builder readPreference(@Nullable final ReadPreference readPreference) {
* @return this
* @mongodb.server.release 4.2
* @since 3.11
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing a commit transaction operation, any explicitly set timeout at these levels takes precedence, rendering this
+ * commit time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
+ @Deprecated
public Builder maxCommitTime(@Nullable final Long maxCommitTime, final TimeUnit timeUnit) {
if (maxCommitTime == null) {
this.maxCommitTimeMS = null;
diff --git a/driver-core/src/main/com/mongodb/client/model/CountOptions.java b/driver-core/src/main/com/mongodb/client/model/CountOptions.java
index 17888908f8d..a029d918773 100644
--- a/driver-core/src/main/com/mongodb/client/model/CountOptions.java
+++ b/driver-core/src/main/com/mongodb/client/model/CountOptions.java
@@ -133,7 +133,20 @@ public CountOptions skip(final int skip) {
*
* @param timeUnit the time unit to return the result in
* @return the maximum execution time in the given time unit
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -145,7 +158,20 @@ public long getMaxTime(final TimeUnit timeUnit) {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public CountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-core/src/main/com/mongodb/client/model/EstimatedDocumentCountOptions.java b/driver-core/src/main/com/mongodb/client/model/EstimatedDocumentCountOptions.java
index a69e9e58a5d..434ad5de6b0 100644
--- a/driver-core/src/main/com/mongodb/client/model/EstimatedDocumentCountOptions.java
+++ b/driver-core/src/main/com/mongodb/client/model/EstimatedDocumentCountOptions.java
@@ -39,7 +39,20 @@ public class EstimatedDocumentCountOptions {
*
* @param timeUnit the time unit to return the result in
* @return the maximum execution time in the given time unit
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -51,7 +64,20 @@ public long getMaxTime(final TimeUnit timeUnit) {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public EstimatedDocumentCountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java
index 3b25cb69692..fb8acedc18c 100644
--- a/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java
+++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java
@@ -96,7 +96,20 @@ public FindOneAndDeleteOptions sort(@Nullable final Bson sort) {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
@@ -108,7 +121,20 @@ public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUn
*
* @param timeUnit the time unit for the result
* @return the max time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
return timeUnit.convert(maxTimeMS, MILLISECONDS);
}
diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java
index fe17d4f24bd..c8ceea398ed 100644
--- a/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java
+++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java
@@ -139,7 +139,20 @@ public FindOneAndReplaceOptions returnDocument(final ReturnDocument returnDocume
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public FindOneAndReplaceOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
@@ -151,7 +164,20 @@ public FindOneAndReplaceOptions maxTime(final long maxTime, final TimeUnit timeU
*
* @param timeUnit the time unit for the result
* @return the max time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
return timeUnit.convert(maxTimeMS, MILLISECONDS);
}
diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java
index a850bdcc0f2..1e7090d01ee 100644
--- a/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java
+++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java
@@ -142,7 +142,20 @@ public FindOneAndUpdateOptions returnDocument(final ReturnDocument returnDocumen
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public FindOneAndUpdateOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
@@ -154,7 +167,20 @@ public FindOneAndUpdateOptions maxTime(final long maxTime, final TimeUnit timeUn
*
* @param timeUnit the time unit for the result
* @return the max time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@code MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@code MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@code MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@code ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
return timeUnit.convert(maxTimeMS, MILLISECONDS);
}
diff --git a/driver-core/src/main/com/mongodb/internal/client/model/FindOptions.java b/driver-core/src/main/com/mongodb/internal/client/model/FindOptions.java
index 55a480f1a96..701f08eaa54 100644
--- a/driver-core/src/main/com/mongodb/internal/client/model/FindOptions.java
+++ b/driver-core/src/main/com/mongodb/internal/client/model/FindOptions.java
@@ -149,7 +149,9 @@ public FindOptions skip(final int skip) {
* @param timeUnit the time unit to return the result in
* @return the maximum execution time in the given time unit
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ * @deprecated This option is deprecated in favor of global operation timeout.
*/
+ @Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -162,7 +164,9 @@ public long getMaxTime(final TimeUnit timeUnit) {
* @param timeUnit the time unit, which may not be null
* @return this
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ * @deprecated This option is deprecated in favor of global operation timeout.
*/
+ @Deprecated
public FindOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
isTrueArgument("maxTime > = 0", maxTime >= 0);
diff --git a/driver-core/src/main/com/mongodb/internal/operation/Operations.java b/driver-core/src/main/com/mongodb/internal/operation/Operations.java
index 3d9a9ba258a..8d79cf7a519 100644
--- a/driver-core/src/main/com/mongodb/internal/operation/Operations.java
+++ b/driver-core/src/main/com/mongodb/internal/operation/Operations.java
@@ -153,6 +153,7 @@ public TimeoutSettings getTimeoutSettings() {
}
CountDocumentsOperation countDocuments(final Bson filter, final CountOptions options) {
+ @SuppressWarnings("deprecation")
CountDocumentsOperation operation = new CountDocumentsOperation(
timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)), assertNotNull(namespace))
.retryReads(retryReads)
@@ -169,6 +170,7 @@ CountDocumentsOperation countDocuments(final Bson filter, final CountOptions opt
return operation;
}
+ @SuppressWarnings("deprecation")
EstimatedDocumentCountOperation estimatedDocumentCount(final EstimatedDocumentCountOptions options) {
return new EstimatedDocumentCountOperation(timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)),
assertNotNull(namespace))
@@ -193,6 +195,7 @@ FindOperation find(final MongoNamespace findNamespace, @Nulla
private FindOperation createFindOperation(final MongoNamespace findNamespace, @Nullable final Bson filter,
final Class resultClass, final FindOptions options) {
+ @SuppressWarnings("deprecation")
FindOperation operation = new FindOperation<>(
timeoutSettings.withMaxTimeAndMaxAwaitTimeMS(options.getMaxTime(MILLISECONDS), options.getMaxAwaitTime(MILLISECONDS)),
findNamespace, codecRegistry.get(resultClass))
@@ -297,6 +300,7 @@ MapReduceWithInlineResultsOperation mapReduce(final String ma
@Nullable final String finalizeFunction, final Class resultClass, final Bson filter, final int limit,
final long maxTimeMS, final boolean jsMode, final Bson scope, final Bson sort, final boolean verbose,
final Collation collation) {
+ @SuppressWarnings("deprecation")
MapReduceWithInlineResultsOperation operation =
new MapReduceWithInlineResultsOperation<>(timeoutSettings.withMaxTimeMS(maxTimeMS),
assertNotNull(namespace), new BsonJavaScript(mapFunction), new BsonJavaScript(reduceFunction),
@@ -314,6 +318,7 @@ MapReduceWithInlineResultsOperation mapReduce(final String ma
return operation;
}
+ @SuppressWarnings("deprecation")
FindAndDeleteOperation findOneAndDelete(final Bson filter, final FindOneAndDeleteOptions options) {
return new FindAndDeleteOperation<>(timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)),
assertNotNull(namespace), writeConcern, retryWrites, getCodec())
@@ -327,6 +332,7 @@ FindAndDeleteOperation findOneAndDelete(final Bson filter, final Find
.let(toBsonDocument(options.getLet()));
}
+ @SuppressWarnings("deprecation")
FindAndReplaceOperation findOneAndReplace(final Bson filter, final TDocument replacement,
final FindOneAndReplaceOptions options) {
return new FindAndReplaceOperation<>(timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)),
@@ -344,6 +350,7 @@ FindAndReplaceOperation findOneAndReplace(final Bson filter, final TD
.let(toBsonDocument(options.getLet()));
}
+ @SuppressWarnings("deprecation")
FindAndUpdateOperation findOneAndUpdate(final Bson filter, final Bson update, final FindOneAndUpdateOptions options) {
return new FindAndUpdateOperation<>(timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)),
assertNotNull(namespace), writeConcern, retryWrites, getCodec(), assertNotNull(toBsonDocument(update)))
@@ -361,6 +368,7 @@ FindAndUpdateOperation findOneAndUpdate(final Bson filter, final Bson
.let(toBsonDocument(options.getLet()));
}
+ @SuppressWarnings("deprecation")
FindAndUpdateOperation findOneAndUpdate(final Bson filter, final List extends Bson> update,
final FindOneAndUpdateOptions options) {
return new FindAndUpdateOperation<>(timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)),
diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncAggregateIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncAggregateIterable.kt
index 439a0ccbb29..afc4baec7a7 100644
--- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncAggregateIterable.kt
+++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncAggregateIterable.kt
@@ -36,7 +36,7 @@ data class SyncAggregateIterable(val wrapped: AggregateFlow) :
}
override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply {
diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncDistinctIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncDistinctIterable.kt
index 0fdc879d610..f77977478be 100644
--- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncDistinctIterable.kt
+++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncDistinctIterable.kt
@@ -28,7 +28,7 @@ data class SyncDistinctIterable(val wrapped: DistinctFlow) :
override fun batchSize(batchSize: Int): SyncDistinctIterable = apply { wrapped.batchSize(batchSize) }
override fun filter(filter: Bson?): SyncDistinctIterable = apply { wrapped.filter(filter) }
override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncDistinctIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun collation(collation: Collation?): SyncDistinctIterable = apply { wrapped.collation(collation) }
override fun comment(comment: String?): SyncDistinctIterable = apply { wrapped.comment(comment) }
diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncFindIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncFindIterable.kt
index 6c500a9cf90..d5650b1bcc4 100644
--- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncFindIterable.kt
+++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncFindIterable.kt
@@ -40,7 +40,7 @@ data class SyncFindIterable(val wrapped: FindFlow) : JFindIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply {
diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlow.kt
index fcf88335457..e1f653591ac 100644
--- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlow.kt
+++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlow.kt
@@ -81,11 +81,23 @@ public class AggregateFlow(private val wrapped: AggregatePublisher)
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, defaults to Milliseconds
* @return this
* @see [Max Time](https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/#cursor.maxTimeMS)
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): AggregateFlow = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ClientSession.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ClientSession.kt
index 6809b0b2777..53637394406 100644
--- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ClientSession.kt
+++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ClientSession.kt
@@ -223,4 +223,4 @@ public class ClientSession(public val wrapped: reactiveClientSession) : jClientS
* @return the options
*/
public fun TransactionOptions.Builder.maxCommitTime(maxCommitTime: Long): TransactionOptions.Builder =
- this.apply { maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) }
diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlow.kt
index 9281e3d1d3c..49dd28fcf1f 100644
--- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlow.kt
+++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlow.kt
@@ -66,10 +66,22 @@ public class DistinctFlow(private val wrapped: DistinctPublisher) :
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, which defaults to Milliseconds
* @return this
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): DistinctFlow = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/FindFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/FindFlow.kt
index 1752f28d8fe..32405d295ee 100644
--- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/FindFlow.kt
+++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/FindFlow.kt
@@ -93,10 +93,22 @@ public class FindFlow(private val wrapped: FindPublisher) : Flow
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, which defaults to Milliseconds
* @return this
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): FindFlow = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollection.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollection.kt
index b9278f8ffcf..992668718d0 100644
--- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollection.kt
+++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollection.kt
@@ -1594,6 +1594,7 @@ public fun CreateIndexOptions.maxTime(maxTime: Long): CreateIndexOptions =
* @param maxTime time in milliseconds
* @return the options
*/
+@Suppress("DEPRECATION")
public fun CountOptions.maxTime(maxTime: Long): CountOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
@@ -1610,7 +1611,7 @@ public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions =
* @return the options
*/
public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocumentCountOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1618,7 +1619,7 @@ public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocume
* @return the options
*/
public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1626,7 +1627,7 @@ public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptio
* @return the options
*/
public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1634,7 +1635,7 @@ public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOpt
* @return the options
*/
public fun FindOneAndUpdateOptions.maxTime(maxTime: Long): FindOneAndUpdateOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* expireAfter extension function
*
diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlowTest.kt
index 07953277d5a..cb108e3b927 100644
--- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlowTest.kt
+++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/AggregateFlowTest.kt
@@ -70,8 +70,8 @@ class AggregateFlowTest {
flow.let(bson)
flow.maxAwaitTime(1)
flow.maxAwaitTime(1, TimeUnit.SECONDS)
- flow.maxTime(1)
- flow.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") flow.maxTime(1)
+ @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS)
flow.timeoutMode(TimeoutMode.ITERATION)
verify(wrapped).allowDiskUse(true)
@@ -84,8 +84,8 @@ class AggregateFlowTest {
verify(wrapped).hintString(hintString)
verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).let(bson)
verify(wrapped).timeoutMode(TimeoutMode.ITERATION)
diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlowTest.kt
index 571c6f579bb..32c928787ba 100644
--- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlowTest.kt
+++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/DistinctFlowTest.kt
@@ -54,8 +54,8 @@ class DistinctFlowTest {
flow.comment(bsonComment)
flow.comment(comment)
flow.filter(filter)
- flow.maxTime(1)
- flow.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") flow.maxTime(1)
+ @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS)
flow.timeoutMode(TimeoutMode.ITERATION)
verify(wrapped).batchSize(batchSize)
@@ -63,8 +63,8 @@ class DistinctFlowTest {
verify(wrapped).comment(bsonComment)
verify(wrapped).comment(comment)
verify(wrapped).filter(filter)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).timeoutMode(TimeoutMode.ITERATION)
verifyNoMoreInteractions(wrapped)
diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/FindFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/FindFlowTest.kt
index 450059c8211..d23667af9ae 100644
--- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/FindFlowTest.kt
+++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/FindFlowTest.kt
@@ -69,8 +69,8 @@ class FindFlowTest {
flow.max(bson)
flow.maxAwaitTime(1)
flow.maxAwaitTime(1, TimeUnit.SECONDS)
- flow.maxTime(1)
- flow.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") flow.maxTime(1)
+ @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS)
flow.min(bson)
flow.noCursorTimeout(true)
flow.partial(true)
@@ -95,8 +95,8 @@ class FindFlowTest {
verify(wrapped).max(bson)
verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).min(bson)
verify(wrapped).noCursorTimeout(true)
verify(wrapped).partial(true)
diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollectionTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollectionTest.kt
index 7be5c068a84..d28396330b7 100644
--- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollectionTest.kt
+++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/MongoCollectionTest.kt
@@ -1005,6 +1005,7 @@ class MongoCollectionTest {
}
@Test
+ @Suppress("DEPRECATION")
fun shouldProvideExtensionFunctionsForTimeBasedOptions() {
val oneThousand = 1000L
diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncAggregateIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncAggregateIterable.kt
index b563c67c368..a172419ede8 100644
--- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncAggregateIterable.kt
+++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncAggregateIterable.kt
@@ -39,7 +39,7 @@ internal class SyncAggregateIterable(val wrapped: AggregateIterable)
}
override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply {
diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncDistinctIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncDistinctIterable.kt
index 91cf8165a3a..4e6c8eba9f8 100644
--- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncDistinctIterable.kt
+++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncDistinctIterable.kt
@@ -31,7 +31,7 @@ internal class SyncDistinctIterable(val wrapped: DistinctIterable) :
}
override fun filter(filter: Bson?): SyncDistinctIterable = apply { wrapped.filter(filter) }
override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncDistinctIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun collation(collation: Collation?): SyncDistinctIterable = apply { wrapped.collation(collation) }
override fun comment(comment: String?): SyncDistinctIterable = apply { wrapped.comment(comment) }
diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncFindIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncFindIterable.kt
index 81247aeb2a0..9be2bcc646e 100644
--- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncFindIterable.kt
+++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncFindIterable.kt
@@ -41,7 +41,7 @@ internal class SyncFindIterable(val wrapped: FindIterable) :
}
override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply {
- wrapped.maxTime(maxTime, timeUnit)
+ @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit)
}
override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply {
diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
index c314cfcbede..e207af1f013 100644
--- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
+++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
@@ -78,11 +78,23 @@ public class AggregateIterable(private val wrapped: JAggregateIterable<
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, defaults to Milliseconds
* @return this
* @see [Max Time](https://www.mongodb.com/docs/manual/reference/method/cursor.maxTimeMS/#cursor.maxTimeMS)
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): AggregateIterable = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt
index 9103689b251..620007e113a 100644
--- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt
+++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt
@@ -95,4 +95,4 @@ public class ClientSession(public val wrapped: JClientSession) : Closeable {
* @return the options
*/
public fun TransactionOptions.Builder.maxCommitTime(maxCommitTime: Long): TransactionOptions.Builder =
- this.apply { maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) }
diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/DistinctIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/DistinctIterable.kt
index 15114a8c9cf..064a1a94c5f 100644
--- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/DistinctIterable.kt
+++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/DistinctIterable.kt
@@ -62,10 +62,22 @@ public class DistinctIterable(private val wrapped: JDistinctIterable
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, which defaults to Milliseconds
* @return this
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): DistinctIterable = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/FindIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/FindIterable.kt
index 3e0363a268b..73905eb654a 100644
--- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/FindIterable.kt
+++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/FindIterable.kt
@@ -88,10 +88,22 @@ public class FindIterable(private val wrapped: JFindIterable) : Mong
/**
* Sets the maximum execution time on the server for this operation.
*
+ * **NOTE**: The maximum execution time option is deprecated. Prefer using the operation execution timeout
+ * configuration options available at the following levels:
+ * - [com.mongodb.MongoClientSettings.Builder.timeout]
+ * - [MongoDatabase.withTimeout]
+ * - [MongoCollection.withTimeout]
+ * - [ClientSession]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
+ *
* @param maxTime the max time
* @param timeUnit the time unit, which defaults to Milliseconds
* @return this
*/
+ @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING)
+ @Suppress("DEPRECATION")
public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): FindIterable = apply {
wrapped.maxTime(maxTime, timeUnit)
}
diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCollection.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCollection.kt
index f941eed48c4..7ad36166384 100644
--- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCollection.kt
+++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCollection.kt
@@ -1451,7 +1451,8 @@ public fun CreateIndexOptions.maxTime(maxTime: Long): CreateIndexOptions =
* @param maxTime time in milliseconds
* @return the options
*/
-public fun CountOptions.maxTime(maxTime: Long): CountOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+public fun CountOptions.maxTime(maxTime: Long): CountOptions =
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1467,7 +1468,7 @@ public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions =
* @return the options
*/
public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocumentCountOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1475,7 +1476,7 @@ public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocume
* @return the options
*/
public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1483,7 +1484,7 @@ public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptio
* @return the options
*/
public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* maxTime extension function
*
@@ -1491,7 +1492,7 @@ public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOpt
* @return the options
*/
public fun FindOneAndUpdateOptions.maxTime(maxTime: Long): FindOneAndUpdateOptions =
- this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) }
+ this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) }
/**
* expireAfter extension function
*
diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt
index 89cc8db421e..b5616a428c6 100644
--- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt
+++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt
@@ -78,8 +78,8 @@ class AggregateIterableTest {
iterable.let(bson)
iterable.maxAwaitTime(1)
iterable.maxAwaitTime(1, TimeUnit.SECONDS)
- iterable.maxTime(1)
- iterable.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") iterable.maxTime(1)
+ @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS)
iterable.timeoutMode(TimeoutMode.ITERATION)
verify(wrapped).allowDiskUse(true)
@@ -93,10 +93,10 @@ class AggregateIterableTest {
verify(wrapped, times(2)).explain(BsonDocument::class.java, verbosity)
verify(wrapped).hint(hint)
verify(wrapped).hintString(hintString)
- verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).let(bson)
verify(wrapped).timeoutMode(TimeoutMode.ITERATION)
diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/DistinctIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/DistinctIterableTest.kt
index 91f5e9b6f44..83863849e8f 100644
--- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/DistinctIterableTest.kt
+++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/DistinctIterableTest.kt
@@ -55,17 +55,17 @@ class DistinctIterableTest {
iterable.comment(bsonComment)
iterable.comment(comment)
iterable.filter(filter)
- iterable.maxTime(1)
- iterable.maxTime(1, TimeUnit.SECONDS)
- iterable.timeoutMode(TimeoutMode.ITERATION)
+ @Suppress("DEPRECATION") iterable.maxTime(1)
+ @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") iterable.timeoutMode(TimeoutMode.ITERATION)
verify(wrapped).batchSize(batchSize)
verify(wrapped).collation(collation)
verify(wrapped).comment(bsonComment)
verify(wrapped).comment(comment)
verify(wrapped).filter(filter)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).timeoutMode(TimeoutMode.ITERATION)
verifyNoMoreInteractions(wrapped)
diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/FindIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/FindIterableTest.kt
index 0f4b2725b2e..1f516d34efe 100644
--- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/FindIterableTest.kt
+++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/FindIterableTest.kt
@@ -77,8 +77,8 @@ class FindIterableTest {
iterable.max(bson)
iterable.maxAwaitTime(1)
iterable.maxAwaitTime(1, TimeUnit.SECONDS)
- iterable.maxTime(1)
- iterable.maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") iterable.maxTime(1)
+ @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS)
iterable.min(bson)
iterable.noCursorTimeout(true)
iterable.partial(true)
@@ -104,10 +104,10 @@ class FindIterableTest {
verify(wrapped).let(bson)
verify(wrapped).limit(1)
verify(wrapped).max(bson)
- verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
- verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
- verify(wrapped).maxTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS)
+ @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS)
verify(wrapped).min(bson)
verify(wrapped).noCursorTimeout(true)
verify(wrapped).partial(true)
diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoCollectionTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoCollectionTest.kt
index e27b7852bba..2ddbb7f2b53 100644
--- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoCollectionTest.kt
+++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoCollectionTest.kt
@@ -876,6 +876,7 @@ class MongoCollectionTest {
}
@Test
+ @Suppress("DEPRECATION")
fun shouldProvideExtensionFunctionsForTimeBasedOptions() {
val oneThousand = 1000L
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/AggregatePublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/AggregatePublisher.java
index afaefdf2eec..152e6b3d7b0 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/AggregatePublisher.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/AggregatePublisher.java
@@ -17,6 +17,7 @@
package com.mongodb.reactivestreams.client;
import com.mongodb.ExplainVerbosity;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.lang.Nullable;
@@ -51,7 +52,20 @@ public interface AggregatePublisher extends Publisher {
* @param timeUnit the time unit, which may not be null
* @return this
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
AggregatePublisher maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/DistinctPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/DistinctPublisher.java
index 030f807fa53..9f41faef876 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/DistinctPublisher.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/DistinctPublisher.java
@@ -16,6 +16,7 @@
package com.mongodb.reactivestreams.client;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.lang.Nullable;
@@ -48,7 +49,20 @@ public interface DistinctPublisher extends Publisher {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
DistinctPublisher maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java
index 06ea4c2c177..a8d747ad3ed 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java
@@ -18,6 +18,7 @@
import com.mongodb.CursorType;
import com.mongodb.ExplainVerbosity;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.Projections;
@@ -77,7 +78,20 @@ public interface FindPublisher extends Publisher {
* @param timeUnit the time unit, which may not be null
* @return this
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
FindPublisher maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/AggregatePublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/AggregatePublisherImpl.java
index 8dce4a63652..71b7dfe9ecd 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/AggregatePublisherImpl.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/AggregatePublisherImpl.java
@@ -82,6 +82,7 @@ public AggregatePublisher timeoutMode(final TimeoutMode timeoutMode) {
}
@Override
+ @SuppressWarnings("deprecation")
public AggregatePublisher maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/DistinctPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/DistinctPublisherImpl.java
index ebbc09c67df..37d062d6f7d 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/DistinctPublisherImpl.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/DistinctPublisherImpl.java
@@ -55,6 +55,7 @@ public DistinctPublisher filter(@Nullable final Bson filter) {
}
@Override
+ @SuppressWarnings("deprecation")
public DistinctPublisher maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/FindPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/FindPublisherImpl.java
index 0c8dc41d2d1..2cd3a6b8a85 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/FindPublisherImpl.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/FindPublisherImpl.java
@@ -67,6 +67,7 @@ public FindPublisher skip(final int skip) {
}
@Override
+ @SuppressWarnings("deprecation")
public FindPublisher maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
findOptions.maxTime(maxTime, timeUnit);
diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSFindPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSFindPublisherImpl.java
index 020b82fee20..c917e64e137 100644
--- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSFindPublisherImpl.java
+++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSFindPublisherImpl.java
@@ -70,6 +70,7 @@ public GridFSFindPublisher filter(@Nullable final Bson filter) {
}
@Override
+ @SuppressWarnings("deprecation")
public GridFSFindPublisher maxTime(final long maxTime, final TimeUnit timeUnit) {
wrapped.maxTime(maxTime, timeUnit);
return this;
diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncAggregateIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncAggregateIterable.java
index 6b81b1f42af..2b5120063e0 100644
--- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncAggregateIterable.java
+++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncAggregateIterable.java
@@ -59,6 +59,7 @@ public AggregateIterable batchSize(final int batchSize) {
}
@Override
+ @SuppressWarnings("deprecation")
public AggregateIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
wrapped.maxTime(maxTime, timeUnit);
return this;
diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncDistinctIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncDistinctIterable.java
index 7f50727621d..33cac07c1ec 100644
--- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncDistinctIterable.java
+++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncDistinctIterable.java
@@ -41,6 +41,7 @@ public DistinctIterable filter(@Nullable final Bson filter) {
}
@Override
+ @SuppressWarnings("deprecation")
public DistinctIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
wrapped.maxTime(maxTime, timeUnit);
return this;
diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncFindIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncFindIterable.java
index 3cf93b9ffb0..71556eab3e7 100644
--- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncFindIterable.java
+++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncFindIterable.java
@@ -61,6 +61,7 @@ public FindIterable skip(final int skip) {
}
@Override
+ @SuppressWarnings("deprecation")
public FindIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
wrapped.maxTime(maxTime, timeUnit);
return this;
diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/AggregatePublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/AggregatePublisherImplTest.java
index 25999f0104c..be45e90f8bb 100644
--- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/AggregatePublisherImplTest.java
+++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/AggregatePublisherImplTest.java
@@ -54,6 +54,7 @@ public class AggregatePublisherImplTest extends TestHelper {
@DisplayName("Should build the expected AggregateOperation")
@Test
+ @SuppressWarnings("deprecation")
void shouldBuildTheExpectedOperation() {
List pipeline = singletonList(BsonDocument.parse("{'$match': 1}"));
@@ -148,6 +149,7 @@ void shouldBuildTheExpectedOperationForHintPlusHintString() {
@DisplayName("Should build the expected AggregateOperation for $out")
@Test
+ @SuppressWarnings("deprecation")
void shouldBuildTheExpectedOperationsForDollarOut() {
String collectionName = "collectionName";
List pipeline = asList(BsonDocument.parse("{'$match': 1}"),
@@ -326,6 +328,7 @@ void shouldBuildTheExpectedOperationsForDollarOutAsDocument() {
@DisplayName("Should build the expected AggregateOperation for $merge document")
@Test
+ @SuppressWarnings("deprecation")
void shouldBuildTheExpectedOperationsForDollarMergeDocument() {
String collectionName = "collectionName";
List pipeline = asList(BsonDocument.parse("{'$match': 1}"),
diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/FindPublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/FindPublisherImplTest.java
index ad642da124e..846b67a82d6 100644
--- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/FindPublisherImplTest.java
+++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/FindPublisherImplTest.java
@@ -45,6 +45,7 @@ public class FindPublisherImplTest extends TestHelper {
@DisplayName("Should build the expected FindOperation")
@Test
+ @SuppressWarnings("deprecation")
void shouldBuildTheExpectedOperation() {
configureBatchCursor();
diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/MongoCollectionImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/MongoCollectionImplTest.java
index 1cd31102611..bfa3e1a29ab 100644
--- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/MongoCollectionImplTest.java
+++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/MongoCollectionImplTest.java
@@ -527,6 +527,7 @@ public void testDropIndexes() {
@Test
+ @SuppressWarnings("deprecation")
public void testEstimatedDocumentCount() {
EstimatedDocumentCountOptions options = new EstimatedDocumentCountOptions().maxTime(1, TimeUnit.MILLISECONDS);
assertAll("estimatedDocumentCount",
diff --git a/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala
index 68bb0fd0bcc..33ecbae3d40 100644
--- a/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala
+++ b/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala
@@ -54,9 +54,20 @@ case class AggregateObservable[TResult](private val wrapped: AggregatePublisher[
* Sets the maximum execution time on the server for this operation.
*
* [[https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/ Max Time]]
+ *
* @param duration the duration
* @return this
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ * - [[org.mongodb.scala.MongoClientSettings.Builder timeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoDatabase.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoCollection.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.ClientSession]]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
+ @deprecated
def maxTime(duration: Duration): AggregateObservable[TResult] = {
wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS)
this
diff --git a/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala
index 6853d1d2ef0..32cdf5f6d8d 100644
--- a/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala
+++ b/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala
@@ -37,9 +37,20 @@ case class DistinctObservable[TResult](private val wrapped: DistinctPublisher[TR
* Sets the query filter to apply to the query.
*
* [[https://www.mongodb.com/docs/manual/reference/method/db.collection.find/ Filter]]
+ *
* @param filter the filter, which may be null.
* @return this
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ * - [[org.mongodb.scala.MongoClientSettings.Builder timeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoDatabase.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoCollection.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.ClientSession]]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
+ @deprecated
def filter(filter: Bson): DistinctObservable[TResult] = {
wrapped.filter(filter)
this
diff --git a/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala
index e98b176dd18..050ca3003cf 100644
--- a/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala
+++ b/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala
@@ -85,9 +85,20 @@ case class FindObservable[TResult](private val wrapped: FindPublisher[TResult])
* Sets the maximum execution time on the server for this operation.
*
* [[https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/ Max Time]]
+ *
* @param duration the duration
* @return this
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ * - [[org.mongodb.scala.MongoClientSettings.Builder timeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoDatabase.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.MongoCollection.withTimeout withTimeout(long, TimeUnit)]]
+ * - [[org.mongodb.scala.ClientSession]]
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum
+ * execution time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
+ @deprecated
def maxTime(duration: Duration): FindObservable[TResult] = {
wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS)
this
diff --git a/driver-sync/src/main/com/mongodb/client/AggregateIterable.java b/driver-sync/src/main/com/mongodb/client/AggregateIterable.java
index d6a237f600e..85fdcc3ff0f 100644
--- a/driver-sync/src/main/com/mongodb/client/AggregateIterable.java
+++ b/driver-sync/src/main/com/mongodb/client/AggregateIterable.java
@@ -17,6 +17,7 @@
package com.mongodb.client;
import com.mongodb.ExplainVerbosity;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.lang.Nullable;
@@ -94,7 +95,20 @@ public interface AggregateIterable extends MongoIterable {
* @param timeUnit the time unit, which may not be null
* @return this
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
AggregateIterable maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-sync/src/main/com/mongodb/client/DistinctIterable.java b/driver-sync/src/main/com/mongodb/client/DistinctIterable.java
index f47024257e0..fd68016be42 100644
--- a/driver-sync/src/main/com/mongodb/client/DistinctIterable.java
+++ b/driver-sync/src/main/com/mongodb/client/DistinctIterable.java
@@ -16,6 +16,7 @@
package com.mongodb.client;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.lang.Nullable;
@@ -47,7 +48,20 @@ public interface DistinctIterable extends MongoIterable {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
DistinctIterable maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-sync/src/main/com/mongodb/client/FindIterable.java b/driver-sync/src/main/com/mongodb/client/FindIterable.java
index d57896938b7..8ad16de6c4e 100644
--- a/driver-sync/src/main/com/mongodb/client/FindIterable.java
+++ b/driver-sync/src/main/com/mongodb/client/FindIterable.java
@@ -18,6 +18,7 @@
import com.mongodb.CursorType;
import com.mongodb.ExplainVerbosity;
+import com.mongodb.MongoClientSettings;
import com.mongodb.client.cursor.TimeoutMode;
import com.mongodb.client.model.Collation;
import com.mongodb.client.model.Projections;
@@ -69,7 +70,20 @@ public interface FindIterable extends MongoIterable {
* @param timeUnit the time unit, which may not be null
* @return this
* @mongodb.driver.manual reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
+ *
+ * @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
+ *
+ *
+ * - {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
+ * - {@link MongoDatabase#withTimeout(long, TimeUnit)}
+ * - {@link MongoCollection#withTimeout(long, TimeUnit)}
+ * - {@link ClientSession}
+ *
+ *
+ * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
+ * irrelevant. If no timeout is specified at these levels, the maximum execution time will be used
*/
+ @Deprecated
FindIterable maxTime(long maxTime, TimeUnit timeUnit);
/**
diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterableImpl.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterableImpl.java
index dbd5625f6fa..bf10f3b6ee2 100644
--- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterableImpl.java
+++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterableImpl.java
@@ -62,6 +62,7 @@ public GridFSFindIterable filter(@Nullable final Bson filter) {
}
@Override
+ @SuppressWarnings("deprecation")
public GridFSFindIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
underlying.maxTime(maxTime, timeUnit);
return this;
diff --git a/driver-sync/src/main/com/mongodb/client/internal/AggregateIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/AggregateIterableImpl.java
index 3f0eceb327c..9f0bfd86f41 100644
--- a/driver-sync/src/main/com/mongodb/client/internal/AggregateIterableImpl.java
+++ b/driver-sync/src/main/com/mongodb/client/internal/AggregateIterableImpl.java
@@ -122,6 +122,7 @@ public AggregateIterable timeoutMode(final TimeoutMode timeoutMode) {
}
@Override
+ @SuppressWarnings("deprecation")
public AggregateIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-sync/src/main/com/mongodb/client/internal/DistinctIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/DistinctIterableImpl.java
index 036f59b5a8c..17bfac03381 100644
--- a/driver-sync/src/main/com/mongodb/client/internal/DistinctIterableImpl.java
+++ b/driver-sync/src/main/com/mongodb/client/internal/DistinctIterableImpl.java
@@ -66,6 +66,7 @@ public DistinctIterable filter(@Nullable final Bson filter) {
}
@Override
+ @SuppressWarnings("deprecation")
public DistinctIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
diff --git a/driver-sync/src/main/com/mongodb/client/internal/FindIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/FindIterableImpl.java
index ca4d4abe6f0..f9446a6f6e3 100644
--- a/driver-sync/src/main/com/mongodb/client/internal/FindIterableImpl.java
+++ b/driver-sync/src/main/com/mongodb/client/internal/FindIterableImpl.java
@@ -81,6 +81,7 @@ public FindIterable skip(final int skip) {
}
@Override
+ @SuppressWarnings("deprecation")
public FindIterable maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
findOptions.maxTime(maxTime, timeUnit);
diff --git a/driver-sync/src/main/com/mongodb/client/internal/MongoCollectionImpl.java b/driver-sync/src/main/com/mongodb/client/internal/MongoCollectionImpl.java
index 8e71db3992a..4bd5f7132d0 100755
--- a/driver-sync/src/main/com/mongodb/client/internal/MongoCollectionImpl.java
+++ b/driver-sync/src/main/com/mongodb/client/internal/MongoCollectionImpl.java
@@ -126,7 +126,8 @@ class MongoCollectionImpl implements MongoCollection {
this.uuidRepresentation = notNull("uuidRepresentation", uuidRepresentation);
this.autoEncryptionSettings = autoEncryptionSettings;
this.timeoutSettings = timeoutSettings;
- this.operations = new SyncOperations<>(namespace, documentClass, readPreference, codecRegistry, readConcern, writeConcern,
+ this.operations = new SyncOperations<>(namespace,
+ documentClass, readPreference, codecRegistry, readConcern, writeConcern,
retryWrites, retryReads, timeoutSettings);
}
diff --git a/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java b/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java
index e49fcd66725..924b96b7151 100644
--- a/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java
+++ b/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java
@@ -313,6 +313,7 @@ BsonDocument getRunCommandResult(final BsonDocument collectionOptions, final Bso
return toResult(response);
}
+ @SuppressWarnings("deprecation") //maxTimeMS
BsonDocument getAggregateResult(final BsonDocument collectionOptions, final BsonDocument arguments,
@Nullable final ClientSession clientSession) {
List pipeline = new ArrayList<>();
@@ -550,6 +551,7 @@ BsonDocument getFindResult(final BsonDocument collectionOptions, final BsonDocum
return toResult(createFindIterable(collectionOptions, arguments, clientSession));
}
+ @SuppressWarnings("deprecation") //maxTimeMS
private FindIterable createFindIterable(final BsonDocument collectionOptions, final BsonDocument arguments,
@Nullable final ClientSession clientSession) {
FindIterable iterable;
diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/Entities.java b/driver-sync/src/test/functional/com/mongodb/client/unified/Entities.java
index a5a2f9496e6..b4ceb8685d3 100644
--- a/driver-sync/src/test/functional/com/mongodb/client/unified/Entities.java
+++ b/driver-sync/src/test/functional/com/mongodb/client/unified/Entities.java
@@ -690,6 +690,7 @@ private void initClientEncryption(final BsonDocument entity, final String id,
putEntity(id, clientEncryptionSupplier.apply(Assertions.notNull("mongoClient", mongoClient), builder.build()), clientEncryptions);
}
+ @SuppressWarnings("deprecation") //maxCommitTimeMS
private TransactionOptions getTransactionOptions(final BsonDocument options) {
TransactionOptions.Builder transactionOptionsBuilder = TransactionOptions.builder();
for (Map.Entry entry : options.entrySet()) {
diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudHelper.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudHelper.java
index 08c4acc117c..dfe3fa23739 100644
--- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudHelper.java
+++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedCrudHelper.java
@@ -360,6 +360,7 @@ OperationResult createFindCursor(final BsonDocument operation) {
}
@NonNull
+ @SuppressWarnings("deprecation") //maxTimeMS
private FindIterable createFindIterable(final BsonDocument operation) {
MongoCollection collection = getMongoCollection(operation);
BsonDocument arguments = operation.getDocument("arguments");
@@ -607,6 +608,7 @@ OperationResult executeFindOneAndDelete(final BsonDocument operation) {
collection.findOneAndDelete(filter, options));
}
+ @SuppressWarnings("deprecation") //maxTimeMS
OperationResult executeAggregate(final BsonDocument operation) {
String entityName = operation.getString("object").getValue();
@@ -1631,6 +1633,7 @@ public OperationResult executeCountDocuments(final BsonDocument operation) {
});
}
+ @SuppressWarnings("deprecation") //maxTimeMS
public OperationResult executeEstimatedDocumentCount(final BsonDocument operation) {
MongoCollection collection = getMongoCollection(operation);
BsonDocument arguments = operation.getDocument("arguments", new BsonDocument());