diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml index 718bfeabbf1..8cb837ffc59 100644 --- a/config/detekt/baseline.xml +++ b/config/detekt/baseline.xml @@ -4,8 +4,8 @@ IteratorNotThrowingNoSuchElementException:MongoCursor.kt$MongoCursor<T : Any> : IteratorCloseable LargeClass:MongoCollectionTest.kt$MongoCollectionTest - LongMethod:FindFlowTest.kt$FindFlowTest$@Test fun shouldCallTheUnderlyingMethods() - LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods() + LongMethod:FindFlowTest.kt$FindFlowTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() + LongMethod:FindIterableTest.kt$FindIterableTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() LongMethod:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues() MaxLineLength:MapReduceFlow.kt$MapReduceFlow$* MaxLineLength:MapReduceIterable.kt$MapReduceIterable$* diff --git a/driver-core/src/main/com/mongodb/ConnectionString.java b/driver-core/src/main/com/mongodb/ConnectionString.java index e34695c996a..5e104fd962b 100644 --- a/driver-core/src/main/com/mongodb/ConnectionString.java +++ b/driver-core/src/main/com/mongodb/ConnectionString.java @@ -1069,6 +1069,7 @@ private ReadPreference buildReadPreference(@Nullable final String readPreference } @Nullable + @SuppressWarnings("deprecation") //wTimeout private WriteConcern buildWriteConcern(@Nullable final Boolean safe, @Nullable final String w, @Nullable final Integer wTimeout, @Nullable final Boolean journal) { @@ -1576,7 +1577,21 @@ public Integer getConnectTimeout() { /** * Gets the socket timeout specified in the connection string. * @return the socket timeout + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this socket timeout + * irrelevant. If no timeout is specified at these levels, the socket timeout will be used. */ + @Deprecated @Nullable public Integer getSocketTimeout() { return socketTimeout; diff --git a/driver-core/src/main/com/mongodb/MongoClientSettings.java b/driver-core/src/main/com/mongodb/MongoClientSettings.java index a904e47a78f..4882471e19c 100644 --- a/driver-core/src/main/com/mongodb/MongoClientSettings.java +++ b/driver-core/src/main/com/mongodb/MongoClientSettings.java @@ -241,6 +241,7 @@ public static final class Builder { private Builder() { } + @SuppressWarnings("deprecation") //readTimeout private Builder(final MongoClientSettings settings) { notNull("settings", settings); applicationName = settings.getApplicationName(); @@ -1117,6 +1118,7 @@ public String toString() { + '}'; } + @SuppressWarnings("deprecation") //readTimeout private MongoClientSettings(final Builder builder) { isTrue("timeoutMS > 0 ", builder.timeoutMS == null || builder.timeoutMS >= 0); readPreference = builder.readPreference; diff --git a/driver-core/src/main/com/mongodb/WriteConcern.java b/driver-core/src/main/com/mongodb/WriteConcern.java index 61c8e510b90..1c794763e22 100644 --- a/driver-core/src/main/com/mongodb/WriteConcern.java +++ b/driver-core/src/main/com/mongodb/WriteConcern.java @@ -170,7 +170,21 @@ public WriteConcern(final String w) { * @param wTimeoutMS the wTimeout in milliseconds, which must be >= 0 * @mongodb.driver.manual reference/write-concern/#w-option w option * @mongodb.driver.manual reference/write-concern/#wtimeout wtimeout option + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering wTimeoutMS irrelevant. + * If no timeout is specified at these levels, the wTimeoutMS will be used. */ + @Deprecated public WriteConcern(final int w, final int wTimeoutMS) { this(w, wTimeoutMS, null); } @@ -232,7 +246,21 @@ public String getWString() { * @see #withWTimeout(long, TimeUnit) * @since 3.2 * @mongodb.driver.manual core/write-concern/#timeouts wTimeout + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this wTimeoutMS irrelevant. + * If no timeout is specified at these levels, the wTimeoutMS will be used. */ + @Deprecated @Nullable public Integer getWTimeout(final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); @@ -384,7 +412,21 @@ public WriteConcern withJournal(@Nullable final Boolean journal) { * @see #getWTimeout(TimeUnit) * @since 3.2 * @mongodb.driver.manual reference/write-concern/#wtimeout wtimeout option + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this wTimeoutMS irrelevant. + * If no timeout is specified at these levels, the wTimeoutMS will be used. */ + @Deprecated public WriteConcern withWTimeout(final long wTimeout, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); long newWTimeOutMS = TimeUnit.MILLISECONDS.convert(wTimeout, timeUnit); diff --git a/driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java b/driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java index e93da219fb1..3c11ad04797 100644 --- a/driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java @@ -18,6 +18,7 @@ import com.mongodb.CreateIndexCommitQuorum; +import com.mongodb.MongoClientSettings; import com.mongodb.lang.Nullable; import java.util.concurrent.TimeUnit; @@ -39,7 +40,21 @@ public class CreateIndexOptions { * * @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: + * + * + * + * 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 +66,21 @@ 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: + * + * + * + * 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 CreateIndexOptions 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/DropIndexOptions.java b/driver-core/src/main/com/mongodb/client/model/DropIndexOptions.java index 982a0253a3d..db7eeb3666a 100644 --- a/driver-core/src/main/com/mongodb/client/model/DropIndexOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/DropIndexOptions.java @@ -17,6 +17,8 @@ package com.mongodb.client.model; +import com.mongodb.MongoClientSettings; + import java.util.concurrent.TimeUnit; import static com.mongodb.assertions.Assertions.notNull; @@ -35,7 +37,20 @@ public class DropIndexOptions { * * @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: + * + * + * + * 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); @@ -47,7 +62,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: + * + * + * + * 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 DropIndexOptions 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/connection/ConnectionPoolSettings.java b/driver-core/src/main/com/mongodb/connection/ConnectionPoolSettings.java index 4b85893640f..161bebc88d5 100644 --- a/driver-core/src/main/com/mongodb/connection/ConnectionPoolSettings.java +++ b/driver-core/src/main/com/mongodb/connection/ConnectionPoolSettings.java @@ -17,6 +17,7 @@ package com.mongodb.connection; import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; import com.mongodb.annotations.Immutable; import com.mongodb.annotations.NotThreadSafe; import com.mongodb.event.ConnectionCheckOutStartedEvent; @@ -177,7 +178,21 @@ public Builder minSize(final int minSize) { * @param timeUnit the TimeUnit for this wait period * @return this * @see #getMaxWaitTime(TimeUnit) + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum wait time + * irrelevant. If no timeout is specified at these levels, the maximum wait time will be used. */ + @Deprecated public Builder maxWaitTime(final long maxWaitTime, final TimeUnit timeUnit) { this.maxWaitTimeMS = MILLISECONDS.convert(maxWaitTime, timeUnit); return this; @@ -382,7 +397,21 @@ public int getMinSize() { * @return the maximum amount of time to wait in the given TimeUnits * @see Builder#maxWaitTime(long, TimeUnit) * @see ConnectionString#getMaxWaitTime() + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum wait time + * irrelevant. If no timeout is specified at these levels, the maximum wait time will be used. */ + @Deprecated public long getMaxWaitTime(final TimeUnit timeUnit) { return timeUnit.convert(maxWaitTimeMS, MILLISECONDS); } diff --git a/driver-core/src/main/com/mongodb/connection/SocketSettings.java b/driver-core/src/main/com/mongodb/connection/SocketSettings.java index 4e6890e785c..3bc3628f3ad 100644 --- a/driver-core/src/main/com/mongodb/connection/SocketSettings.java +++ b/driver-core/src/main/com/mongodb/connection/SocketSettings.java @@ -18,6 +18,7 @@ import com.mongodb.Block; import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; import com.mongodb.annotations.Immutable; import java.util.Objects; @@ -113,7 +114,21 @@ public Builder connectTimeout(final long connectTimeout, final TimeUnit timeUnit * @param timeUnit the time unit * @return this * @see #getReadTimeout(TimeUnit) + * + * @deprecated Prefer using the operation execution timeout configuration options available at the following levels: + * + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this read timeout irrelevant. + * If no timeout is specified at these levels, the read timeout will be used. */ + @Deprecated public Builder readTimeout(final long readTimeout, final TimeUnit timeUnit) { this.readTimeoutMS = timeoutArgumentToMillis(readTimeout, timeUnit); return this; @@ -161,6 +176,7 @@ public SocketSettings.Builder applyToProxySettings(final Block + *
  • {@link MongoClientSettings.Builder#getTimeout(TimeUnit)}
  • + *
  • {@code MongoDatabase#getTimeout(TimeUnit)}
  • + *
  • {@code MongoCollection#getTimeout(TimeUnit)}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • + * + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this read timeout irrelevant. + * If no timeout is specified at these levels, the read timeout will be used. */ + @Deprecated public int getReadTimeout(final TimeUnit timeUnit) { return (int) timeUnit.convert(readTimeoutMS, MILLISECONDS); } diff --git a/driver-core/src/main/com/mongodb/internal/TimeoutSettings.java b/driver-core/src/main/com/mongodb/internal/TimeoutSettings.java index 05b5b9be09b..f47d8b4d533 100644 --- a/driver-core/src/main/com/mongodb/internal/TimeoutSettings.java +++ b/driver-core/src/main/com/mongodb/internal/TimeoutSettings.java @@ -51,6 +51,7 @@ public class TimeoutSettings { public static final TimeoutSettings DEFAULT = create(MongoClientSettings.builder().build()); + @SuppressWarnings("deprecation") public static TimeoutSettings create(final MongoClientSettings settings) { return new TimeoutSettings( settings.getClusterSettings().getServerSelectionTimeout(TimeUnit.MILLISECONDS), @@ -60,6 +61,7 @@ public static TimeoutSettings create(final MongoClientSettings settings) { settings.getConnectionPoolSettings().getMaxWaitTime(TimeUnit.MILLISECONDS)); } + @SuppressWarnings("deprecation") public static TimeoutSettings createHeartbeatSettings(final MongoClientSettings settings) { return new TimeoutSettings( settings.getClusterSettings().getServerSelectionTimeout(TimeUnit.MILLISECONDS), diff --git a/driver-core/src/main/com/mongodb/internal/capi/MongoCryptHelper.java b/driver-core/src/main/com/mongodb/internal/capi/MongoCryptHelper.java index bdd80562714..8bf8e21c6d7 100644 --- a/driver-core/src/main/com/mongodb/internal/capi/MongoCryptHelper.java +++ b/driver-core/src/main/com/mongodb/internal/capi/MongoCryptHelper.java @@ -173,6 +173,7 @@ public static List createMongocryptdSpawnArgs(final Map return spawnArgs; } + @SuppressWarnings("deprecation") // builder.readTimeout public static MongoClientSettings createMongocryptdClientSettings(@Nullable final String connectionString) { return MongoClientSettings.builder() diff --git a/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java b/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java index 02d8c9652a1..474594dec1c 100644 --- a/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java +++ b/driver-core/src/main/com/mongodb/internal/connection/DefaultConnectionPool.java @@ -207,6 +207,7 @@ public InternalConnection get(final OperationContext operationContext) { } @Override + @SuppressWarnings("deprecation") //maxWaitTime public void getAsync(final OperationContext operationContext, final SingleResultCallback callback) { StartTime checkoutStart = connectionCheckoutStarted(operationContext); Timeout maxWaitTimeout = checkoutStart.timeoutAfterOrInfiniteIfNegative(settings.getMaxWaitTime(NANOSECONDS), NANOSECONDS); @@ -480,6 +481,7 @@ private boolean expired(final long startTime, final long curTime, final long max * Send both current and deprecated events in order to preserve backwards compatibility. * Must not throw {@link Exception}s. */ + @SuppressWarnings("deprecation") // settings.getMaxWaitTime private void connectionPoolCreated(final ConnectionPoolListener connectionPoolListener, final ServerId serverId, final ConnectionPoolSettings settings) { ClusterId clusterId = serverId.getClusterId(); diff --git a/driver-core/src/main/com/mongodb/internal/operation/CommitTransactionOperation.java b/driver-core/src/main/com/mongodb/internal/operation/CommitTransactionOperation.java index 933776af3e0..34e3baaa557 100644 --- a/driver-core/src/main/com/mongodb/internal/operation/CommitTransactionOperation.java +++ b/driver-core/src/main/com/mongodb/internal/operation/CommitTransactionOperation.java @@ -136,6 +136,7 @@ CommandCreator getCommandCreator() { } @Override + @SuppressWarnings("deprecation") //wTimeout protected Function getRetryCommandModifier() { return command -> { WriteConcern retryWriteConcern = getWriteConcern().withW("majority"); diff --git a/driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java b/driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java index ede32597d85..aa0bf509484 100644 --- a/driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java +++ b/driver-core/src/main/com/mongodb/internal/operation/SyncOperations.java @@ -125,12 +125,12 @@ public TimeoutSettings createTimeoutSettings(final FindOneAndUpdateOptions optio return timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)); } - // TODO (CSOT) @SuppressWarnings("deprecation") // MaxTime + @SuppressWarnings("deprecation") // MaxTime public TimeoutSettings createTimeoutSettings(final CreateIndexOptions options) { return timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)); } - // TODO (CSOT) @SuppressWarnings("deprecation") // MaxTime + @SuppressWarnings("deprecation") // MaxTime public TimeoutSettings createTimeoutSettings(final DropIndexOptions options) { return timeoutSettings.withMaxTimeMS(options.getMaxTime(MILLISECONDS)); } diff --git a/driver-core/src/test/functional/com/mongodb/ClusterFixture.java b/driver-core/src/test/functional/com/mongodb/ClusterFixture.java index ad6cd590693..bb60f61ebc6 100644 --- a/driver-core/src/test/functional/com/mongodb/ClusterFixture.java +++ b/driver-core/src/test/functional/com/mongodb/ClusterFixture.java @@ -466,6 +466,7 @@ private static Cluster createCluster(final MongoCredential credential, final Str LoggerSettings.builder().build(), null, null, null, Collections.emptyList(), getServerApi(), null); } + @SuppressWarnings("deprecation") //readTimeout private static Cluster createCluster(final ConnectionString connectionString, final StreamFactory streamFactory) { MongoClientSettings mongoClientSettings = MongoClientSettings.builder().applyConnectionString(connectionString).build(); diff --git a/driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java b/driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java index c5b90aa95fa..52238142b7e 100644 --- a/driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java +++ b/driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java @@ -94,7 +94,7 @@ protected void testValidHostIdentifiers() { assertExpectedHosts(connectionString.getHosts()); } - @SuppressWarnings("ConstantConditions") + @SuppressWarnings({"ConstantConditions", "deprecation"}) protected void testValidOptions() { ConnectionString connectionString = null; diff --git a/driver-core/src/test/unit/com/mongodb/WriteConcernConnectionStringTest.java b/driver-core/src/test/unit/com/mongodb/WriteConcernConnectionStringTest.java index ec5815abfc9..e406d22e549 100644 --- a/driver-core/src/test/unit/com/mongodb/WriteConcernConnectionStringTest.java +++ b/driver-core/src/test/unit/com/mongodb/WriteConcernConnectionStringTest.java @@ -64,6 +64,7 @@ public void shouldPassAllOutcomes() { } } + @SuppressWarnings("deprecation") //wTimeout private WriteConcern getExpectedWriteConcern() { BsonDocument writeConcernDocument = definition.getDocument("writeConcern"); diff --git a/driver-core/src/test/unit/com/mongodb/WriteConcernDocumentTest.java b/driver-core/src/test/unit/com/mongodb/WriteConcernDocumentTest.java index 1c828a42f15..f90b4f405e8 100644 --- a/driver-core/src/test/unit/com/mongodb/WriteConcernDocumentTest.java +++ b/driver-core/src/test/unit/com/mongodb/WriteConcernDocumentTest.java @@ -63,6 +63,7 @@ public void shouldPassAllOutcomes() { } } + @SuppressWarnings("deprecation") //wTimeoutMS private WriteConcern getWriteConcern(final BsonDocument writeConcernDocument) { BsonValue wValue = writeConcernDocument.get("w"); WriteConcern retVal; diff --git a/driver-core/src/test/unit/com/mongodb/connection/SocketSettingsTest.java b/driver-core/src/test/unit/com/mongodb/connection/SocketSettingsTest.java index bf092be0f54..bca0731360d 100644 --- a/driver-core/src/test/unit/com/mongodb/connection/SocketSettingsTest.java +++ b/driver-core/src/test/unit/com/mongodb/connection/SocketSettingsTest.java @@ -31,6 +31,7 @@ void connectTimeoutThrowsIfArgumentIsTooLarge() { } @Test + @SuppressWarnings("deprecation") //readTimeout void readTimeoutThrowsIfArgumentIsTooLarge() { assertThrows(IllegalArgumentException.class, () -> SocketSettings.builder().readTimeout(Integer.MAX_VALUE / 2, TimeUnit.SECONDS)); } 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 afc4baec7a7..23fcb0660ef 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 @@ -35,8 +35,10 @@ data class SyncAggregateIterable(val wrapped: AggregateFlow) : wrapped.allowDiskUse(allowDiskUse) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + 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 f77977478be..3fe9e4463e7 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 @@ -27,8 +27,10 @@ data class SyncDistinctIterable(val wrapped: DistinctFlow) : JDistinctIterable, SyncMongoIterable(wrapped) { override fun batchSize(batchSize: Int): SyncDistinctIterable = apply { wrapped.batchSize(batchSize) } override fun filter(filter: Bson?): SyncDistinctIterable = apply { wrapped.filter(filter) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncDistinctIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + 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 d5650b1bcc4..e1000f77dc4 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 @@ -39,8 +39,10 @@ data class SyncFindIterable(val wrapped: FindFlow) : JFindIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + wrapped.maxTime(maxTime, timeUnit) } override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply { diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionNamesIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionNamesIterable.kt index f110a744047..34481ae2e48 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionNamesIterable.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionNamesIterable.kt @@ -26,8 +26,8 @@ data class SyncListCollectionNamesIterable(val wrapped: ListCollectionNamesFlow) override fun batchSize(batchSize: Int): SyncListCollectionNamesIterable = apply { wrapped.batchSize(batchSize) } - @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListCollectionNamesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionsIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionsIterable.kt index ab1853c756d..8d4ab239e3b 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionsIterable.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListCollectionsIterable.kt @@ -26,6 +26,9 @@ data class SyncListCollectionsIterable(val wrapped: ListCollectionsFlow JListCollectionsIterable, SyncMongoIterable(wrapped) { override fun batchSize(batchSize: Int): SyncListCollectionsIterable = apply { wrapped.batchSize(batchSize) } + + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListCollectionsIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListDatabasesIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListDatabasesIterable.kt index 4563dfe4a4f..e23aff424a9 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListDatabasesIterable.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListDatabasesIterable.kt @@ -27,6 +27,8 @@ data class SyncListDatabasesIterable(val wrapped: ListDatabasesFlow) override fun batchSize(batchSize: Int): SyncListDatabasesIterable = apply { wrapped.batchSize(batchSize) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListDatabasesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListIndexesIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListIndexesIterable.kt index 0e329c7bcdd..ee4bceedefb 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListIndexesIterable.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListIndexesIterable.kt @@ -24,6 +24,8 @@ import org.bson.BsonValue data class SyncListIndexesIterable(val wrapped: ListIndexesFlow) : JListIndexesIterable, SyncMongoIterable(wrapped) { override fun batchSize(batchSize: Int): SyncListIndexesIterable = apply { wrapped.batchSize(batchSize) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListIndexesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListSearchIndexesIterable.kt b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListSearchIndexesIterable.kt index a7df87779df..09c3ee01ffc 100644 --- a/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListSearchIndexesIterable.kt +++ b/driver-kotlin-coroutine/src/integration/kotlin/com/mongodb/kotlin/client/coroutine/syncadapter/SyncListSearchIndexesIterable.kt @@ -36,6 +36,8 @@ internal class SyncListSearchIndexesIterable(val wrapped: ListSearchInd wrapped.allowDiskUse(allowDiskUse) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListSearchIndexesIterable = 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 77d8ea94554..829f1abf5b8 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 @@ -235,5 +235,6 @@ public class ClientSession(public val wrapped: reactiveClientSession) : jClientS * @param maxCommitTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun TransactionOptions.Builder.maxCommitTime(maxCommitTime: Long): TransactionOptions.Builder = - this.apply { @Suppress("DEPRECATION") maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) } + this.apply { maxCommitTime(maxCommitTime, TimeUnit.MILLISECONDS) } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlow.kt index eb5aecc7a0a..650c298e8f1 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlow.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlow.kt @@ -59,11 +59,22 @@ public class ListCollectionsFlow(private val wrapped: ListCollectionsPu /** * 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 + * @param timeUnit the time unit, which defaults to Milliseconds * @return this - * @see [Max Time](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListCollectionsFlow = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlow.kt index 60670429029..a9d1fd87a67 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlow.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlow.kt @@ -56,11 +56,22 @@ public class ListDatabasesFlow(private val wrapped: ListDatabasesPublis /** * 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/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListDatabasesFlow = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlow.kt index dd736b977ff..6ac8678ecbf 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlow.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlow.kt @@ -55,11 +55,22 @@ public class ListIndexesFlow(private val wrapped: ListIndexesPublisher< /** * 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/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListIndexesFlow = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListSearchIndexesFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListSearchIndexesFlow.kt index 0cbeaf70de9..a6d81e53742 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListSearchIndexesFlow.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ListSearchIndexesFlow.kt @@ -82,10 +82,22 @@ public class ListSearchIndexesFlow(private val wrapped: ListSearchIndex /** * 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. */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListSearchIndexesFlow = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlow.kt b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlow.kt index 3f4a319090b..e78b1f1e414 100644 --- a/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlow.kt +++ b/driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/MapReduceFlow.kt @@ -152,10 +152,19 @@ public class MapReduceFlow(private val wrapped: MapReducePublisher) /** * 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) */ public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): MapReduceFlow = 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 d04d6579c02..aa3751762b4 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 @@ -1586,6 +1586,7 @@ public class MongoCollection(private val wrapped: JMongoCollection) * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun CreateIndexOptions.maxTime(maxTime: Long): CreateIndexOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** @@ -1602,6 +1603,7 @@ public fun CountOptions.maxTime(maxTime: Long): CountOptions = this.apply { maxT * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** @@ -1610,32 +1612,36 @@ public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions = * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocumentCountOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndUpdateOptions.maxTime(maxTime: Long): FindOneAndUpdateOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { 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 cb108e3b927..a9dfaab4e47 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 @@ -46,6 +46,7 @@ class AggregateFlowTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: AggregatePublisher = mock() val flow = AggregateFlow(wrapped) @@ -70,8 +71,8 @@ class AggregateFlowTest { flow.let(bson) flow.maxAwaitTime(1) flow.maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") flow.maxTime(1) - @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS) + flow.maxTime(1) + flow.maxTime(1, TimeUnit.SECONDS) flow.timeoutMode(TimeoutMode.ITERATION) verify(wrapped).allowDiskUse(true) @@ -84,8 +85,8 @@ class AggregateFlowTest { verify(wrapped).hintString(hintString) verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS) verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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 32c928787ba..1407cee09c0 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 @@ -39,6 +39,7 @@ class DistinctFlowTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: DistinctPublisher = mock() val flow = DistinctFlow(wrapped) @@ -54,8 +55,8 @@ class DistinctFlowTest { flow.comment(bsonComment) flow.comment(comment) flow.filter(filter) - @Suppress("DEPRECATION") flow.maxTime(1) - @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS) + flow.maxTime(1) + flow.maxTime(1, TimeUnit.SECONDS) flow.timeoutMode(TimeoutMode.ITERATION) verify(wrapped).batchSize(batchSize) @@ -63,8 +64,8 @@ class DistinctFlowTest { verify(wrapped).comment(bsonComment) verify(wrapped).comment(comment) verify(wrapped).filter(filter) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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 d23667af9ae..c0556f7655a 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 @@ -41,6 +41,7 @@ class FindFlowTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: FindPublisher = mock() val flow = FindFlow(wrapped) @@ -69,8 +70,8 @@ class FindFlowTest { flow.max(bson) flow.maxAwaitTime(1) flow.maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") flow.maxTime(1) - @Suppress("DEPRECATION") flow.maxTime(1, TimeUnit.SECONDS) + flow.maxTime(1) + flow.maxTime(1, TimeUnit.SECONDS) flow.min(bson) flow.noCursorTimeout(true) flow.partial(true) @@ -95,8 +96,8 @@ class FindFlowTest { verify(wrapped).max(bson) verify(wrapped).maxAwaitTime(1, TimeUnit.MILLISECONDS) verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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/ListCollectionsFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlowTest.kt index 59c6f896c86..0e00883e2ed 100644 --- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlowTest.kt +++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListCollectionsFlowTest.kt @@ -28,6 +28,7 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions +@Suppress("DEPRECATION") // maxTime class ListCollectionsFlowTest { @Test fun shouldHaveTheSameMethods() { diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlowTest.kt index eac18960b3f..7e441b4c6fd 100644 --- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlowTest.kt +++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListDatabasesFlowTest.kt @@ -28,6 +28,7 @@ import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions +@Suppress("DEPRECATION") // maxTime class ListDatabasesFlowTest { @Test fun shouldHaveTheSameMethods() { diff --git a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlowTest.kt b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlowTest.kt index d84765d428b..37f215c2ed3 100644 --- a/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlowTest.kt +++ b/driver-kotlin-coroutine/src/test/kotlin/com/mongodb/kotlin/client/coroutine/ListIndexesFlowTest.kt @@ -38,6 +38,7 @@ class ListIndexesFlowTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: ListIndexesPublisher = mock() val flow = ListIndexesFlow(wrapped) 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 d28396330b7..ac2ab0669f1 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 @@ -912,6 +912,7 @@ class MongoCollectionTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingDropIndex() { val mongoCollection = MongoCollection(wrapped) val indexName = "index" @@ -952,6 +953,7 @@ class MongoCollectionTest { } @Test + @Suppress("DEPRECATION") // maxtime fun shouldCallTheUnderlyingDropIndexes() { val mongoCollection = MongoCollection(wrapped) val defaultOptions = DropIndexOptions() 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 a172419ede8..ab097df27bb 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 @@ -38,8 +38,10 @@ internal class SyncAggregateIterable(val wrapped: AggregateIterable) wrapped.allowDiskUse(allowDiskUse) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncAggregateIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + 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 4e6c8eba9f8..1e4bb999944 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 @@ -30,8 +30,10 @@ internal class SyncDistinctIterable(val wrapped: DistinctIterable) : wrapped.timeoutMode(timeoutMode) } override fun filter(filter: Bson?): SyncDistinctIterable = apply { wrapped.filter(filter) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncDistinctIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + 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 9be2bcc646e..85f332137a3 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 @@ -40,8 +40,10 @@ internal class SyncFindIterable(val wrapped: FindIterable) : wrapped.allowDiskUse(allowDiskUse) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply { - @Suppress("DEPRECATION") wrapped.maxTime(maxTime, timeUnit) + wrapped.maxTime(maxTime, timeUnit) } override fun maxAwaitTime(maxAwaitTime: Long, timeUnit: TimeUnit): SyncFindIterable = apply { diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionNamesIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionNamesIterable.kt index 7477c9c9de1..729b1eb2746 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionNamesIterable.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionNamesIterable.kt @@ -26,8 +26,8 @@ internal class SyncListCollectionNamesIterable(val wrapped: ListCollectionNamesI override fun batchSize(batchSize: Int): SyncListCollectionNamesIterable = apply { wrapped.batchSize(batchSize) } - @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListCollectionNamesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionsIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionsIterable.kt index f38e7eed5e7..8230bc97540 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionsIterable.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListCollectionsIterable.kt @@ -30,6 +30,8 @@ internal class SyncListCollectionsIterable(val wrapped: ListCollections wrapped.timeoutMode(timeoutMode) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListCollectionsIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListDatabasesIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListDatabasesIterable.kt index 34874827826..f5e5f4aaccc 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListDatabasesIterable.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListDatabasesIterable.kt @@ -30,6 +30,8 @@ internal class SyncListDatabasesIterable(val wrapped: ListDatabasesIter wrapped.timeoutMode(timeoutMode) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListDatabasesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListIndexesIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListIndexesIterable.kt index 56e5fec91cd..e696fab8868 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListIndexesIterable.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListIndexesIterable.kt @@ -27,6 +27,9 @@ internal class SyncListIndexesIterable(val wrapped: ListIndexesIterable override fun timeoutMode(timeoutMode: TimeoutMode): SyncListIndexesIterable = apply { wrapped.timeoutMode(timeoutMode) } + + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListIndexesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListSearchIndexesIterable.kt b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListSearchIndexesIterable.kt index b0e6d522b7e..495874ec189 100644 --- a/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListSearchIndexesIterable.kt +++ b/driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/syncadapter/SyncListSearchIndexesIterable.kt @@ -36,6 +36,8 @@ internal class SyncListSearchIndexesIterable(val wrapped: ListSearchInd wrapped.allowDiskUse(allowDiskUse) } + @Suppress("DEPRECATION") + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.HIDDEN) override fun maxTime(maxTime: Long, timeUnit: TimeUnit): SyncListSearchIndexesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListCollectionsIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListCollectionsIterable.kt index 8e3473aa8a4..01b796c3781 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListCollectionsIterable.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListCollectionsIterable.kt @@ -53,11 +53,22 @@ public class ListCollectionsIterable(private val wrapped: JListCollecti /** * 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/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListCollectionsIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListDatabasesIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListDatabasesIterable.kt index de8be15727e..8777ab1ce41 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListDatabasesIterable.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListDatabasesIterable.kt @@ -53,11 +53,22 @@ public class ListDatabasesIterable(private val wrapped: JListDatabasesI /** * 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/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListDatabasesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListIndexesIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListIndexesIterable.kt index 1fdddbd7d28..896ebd158d9 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListIndexesIterable.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListIndexesIterable.kt @@ -51,11 +51,22 @@ public class ListIndexesIterable(private val wrapped: JListIndexesItera /** * 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/operator/meta/maxTimeMS/) */ + @Deprecated("Prefer using the operation execution timeout configuration option", level = DeprecationLevel.WARNING) + @Suppress("DEPRECATION") public fun maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS): ListIndexesIterable = apply { wrapped.maxTime(maxTime, timeUnit) } diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListSearchIndexesIterable.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListSearchIndexesIterable.kt index 1214e8026e0..4f864548b8e 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListSearchIndexesIterable.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ListSearchIndexesIterable.kt @@ -74,11 +74,22 @@ public class ListSearchIndexesIterable(private val wrapped: JListSearch /** * 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): ListSearchIndexesIterable = 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 9036cf23cdb..4e8b3606147 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 @@ -1443,6 +1443,7 @@ public class MongoCollection(private val wrapped: JMongoCollection) * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun CreateIndexOptions.maxTime(maxTime: Long): CreateIndexOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** @@ -1451,14 +1452,15 @@ public fun CreateIndexOptions.maxTime(maxTime: Long): CreateIndexOptions = * @param maxTime time in milliseconds * @return the options */ -public fun CountOptions.maxTime(maxTime: Long): CountOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } +@Suppress("DEPRECATION") +public fun CountOptions.maxTime(maxTime: Long): CountOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions = this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** @@ -1467,32 +1469,36 @@ public fun DropIndexOptions.maxTime(maxTime: Long): DropIndexOptions = * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun EstimatedDocumentCountOptions.maxTime(maxTime: Long): EstimatedDocumentCountOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndDeleteOptions.maxTime(maxTime: Long): FindOneAndDeleteOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndReplaceOptions.maxTime(maxTime: Long): FindOneAndReplaceOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { maxTime(maxTime, TimeUnit.MILLISECONDS) } /** * maxTime extension function * * @param maxTime time in milliseconds * @return the options */ +@Suppress("DEPRECATION") public fun FindOneAndUpdateOptions.maxTime(maxTime: Long): FindOneAndUpdateOptions = - this.apply { @Suppress("DEPRECATION") maxTime(maxTime, TimeUnit.MILLISECONDS) } + this.apply { 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 b5616a428c6..40b99d025b5 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 @@ -44,6 +44,7 @@ class AggregateIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JAggregateIterable = mock() val iterable = AggregateIterable(wrapped) @@ -78,8 +79,8 @@ class AggregateIterableTest { iterable.let(bson) iterable.maxAwaitTime(1) iterable.maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") iterable.maxTime(1) - @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS) + iterable.maxTime(1) + iterable.maxTime(1, TimeUnit.SECONDS) iterable.timeoutMode(TimeoutMode.ITERATION) verify(wrapped).allowDiskUse(true) @@ -93,10 +94,10 @@ class AggregateIterableTest { verify(wrapped, times(2)).explain(BsonDocument::class.java, verbosity) verify(wrapped).hint(hint) verify(wrapped).hintString(hintString) - @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).maxAwaitTime(1, TimeUnit.MILLISECONDS) + verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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 83863849e8f..ba56a7a0426 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 @@ -40,6 +40,7 @@ class DistinctIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JDistinctIterable = mock() val iterable = DistinctIterable(wrapped) @@ -55,17 +56,17 @@ class DistinctIterableTest { iterable.comment(bsonComment) iterable.comment(comment) iterable.filter(filter) - @Suppress("DEPRECATION") iterable.maxTime(1) - @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") iterable.timeoutMode(TimeoutMode.ITERATION) + iterable.maxTime(1) + iterable.maxTime(1, TimeUnit.SECONDS) + iterable.timeoutMode(TimeoutMode.ITERATION) verify(wrapped).batchSize(batchSize) verify(wrapped).collation(collation) verify(wrapped).comment(bsonComment) verify(wrapped).comment(comment) verify(wrapped).filter(filter) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) - @Suppress("DEPRECATION") verify(wrapped).maxTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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 1f516d34efe..b392baadc8c 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 @@ -39,6 +39,7 @@ class FindIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JFindIterable = mock() val iterable = FindIterable(wrapped) @@ -77,8 +78,8 @@ class FindIterableTest { iterable.max(bson) iterable.maxAwaitTime(1) iterable.maxAwaitTime(1, TimeUnit.SECONDS) - @Suppress("DEPRECATION") iterable.maxTime(1) - @Suppress("DEPRECATION") iterable.maxTime(1, TimeUnit.SECONDS) + iterable.maxTime(1) + iterable.maxTime(1, TimeUnit.SECONDS) iterable.min(bson) iterable.noCursorTimeout(true) iterable.partial(true) @@ -104,10 +105,10 @@ class FindIterableTest { verify(wrapped).let(bson) verify(wrapped).limit(1) verify(wrapped).max(bson) - @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).maxAwaitTime(1, TimeUnit.MILLISECONDS) + verify(wrapped).maxAwaitTime(1, TimeUnit.SECONDS) + verify(wrapped).maxTime(1, TimeUnit.MILLISECONDS) + 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/ListCollectionsIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListCollectionsIterableTest.kt index 26dd071768c..b158b160a4f 100644 --- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListCollectionsIterableTest.kt +++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListCollectionsIterableTest.kt @@ -39,6 +39,7 @@ class ListCollectionsIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JListCollectionsIterable = mock() val iterable = ListCollectionsIterable(wrapped) diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt index a1c95cad1a0..2beb92e7cd7 100644 --- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt +++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt @@ -39,6 +39,7 @@ class ListDatabasesIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JListDatabasesIterable = mock() val iterable = ListDatabasesIterable(wrapped) diff --git a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListIndexesIterableTest.kt b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListIndexesIterableTest.kt index 08bd5b4e685..5309f50d298 100644 --- a/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListIndexesIterableTest.kt +++ b/driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListIndexesIterableTest.kt @@ -38,6 +38,7 @@ class ListIndexesIterableTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods() { val wrapped: JListIndexesIterable = mock() val iterable = ListIndexesIterable(wrapped) 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 2ddbb7f2b53..54c5499d23a 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 @@ -811,6 +811,7 @@ class MongoCollectionTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingDropIndex() { val mongoCollection = MongoCollection(wrapped) val indexName = "index" @@ -839,6 +840,7 @@ class MongoCollectionTest { } @Test + @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingDropIndexes() { val mongoCollection = MongoCollection(wrapped) val defaultOptions = DropIndexOptions() diff --git a/driver-legacy/src/main/com/mongodb/MongoClientOptions.java b/driver-legacy/src/main/com/mongodb/MongoClientOptions.java index 8c4442f237c..602df1cecf3 100644 --- a/driver-legacy/src/main/com/mongodb/MongoClientOptions.java +++ b/driver-legacy/src/main/com/mongodb/MongoClientOptions.java @@ -196,6 +196,7 @@ public int getServerSelectionTimeout() { * * @return the maximum wait time. */ + @SuppressWarnings("deprecation") public int getMaxWaitTime() { return toIntExact(wrapped.getConnectionPoolSettings().getMaxWaitTime(MILLISECONDS)); } @@ -288,6 +289,7 @@ public int getConnectTimeout() { * * @return the socket timeout, in milliseconds */ + @SuppressWarnings("deprecation") public int getSocketTimeout() { return wrapped.getSocketSettings().getReadTimeout(MILLISECONDS); } @@ -338,6 +340,7 @@ public int getHeartbeatConnectTimeout() { * @return the heartbeat socket timeout, in milliseconds * @since 2.12 */ + @SuppressWarnings("deprecation") public int getHeartbeatSocketTimeout() { return wrapped.getHeartbeatSocketSettings().getReadTimeout(MILLISECONDS); } @@ -855,6 +858,7 @@ public Builder serverSelectionTimeout(final int serverSelectionTimeout) { * @return {@code this} * @see MongoClientOptions#getMaxWaitTime() */ + @SuppressWarnings("deprecation") public Builder maxWaitTime(final int maxWaitTime) { wrapped.applyToConnectionPoolSettings(builder -> builder.maxWaitTime(maxWaitTime, MILLISECONDS)); return this; @@ -949,6 +953,7 @@ public Builder connectTimeout(final int connectTimeout) { * @return {@code this} * @see com.mongodb.MongoClientOptions#getSocketTimeout() */ + @SuppressWarnings("deprecation") public Builder socketTimeout(final int socketTimeout) { wrapped.applyToSocketSettings(builder -> builder.readTimeout(socketTimeout, MILLISECONDS)); return this; diff --git a/driver-legacy/src/main/com/mongodb/MongoClientURI.java b/driver-legacy/src/main/com/mongodb/MongoClientURI.java index 51863ebd0af..15d2d95e7c9 100644 --- a/driver-legacy/src/main/com/mongodb/MongoClientURI.java +++ b/driver-legacy/src/main/com/mongodb/MongoClientURI.java @@ -365,6 +365,7 @@ public String getSrvServiceName() { * * @return the MongoClientOptions based on this URI. */ + @SuppressWarnings("deprecation") //proxied.getSocketTimeout public MongoClientOptions getOptions() { ReadPreference readPreference = proxied.getReadPreference(); if (readPreference != null) { diff --git a/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java b/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java index 9631b4deb40..66d93ed30e0 100644 --- a/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java +++ b/driver-legacy/src/test/functional/com/mongodb/DBCollectionTest.java @@ -754,6 +754,7 @@ public void testBulkWriteException() { public void testWriteConcernExceptionOnInsert() throws UnknownHostException { assumeThat(isDiscoverableReplicaSet(), is(true)); try { + @SuppressWarnings("deprecation") WriteResult res = collection.insert(new BasicDBObject(), new WriteConcern(5).withWTimeout(1, MILLISECONDS)); fail("Write should have failed but succeeded with result " + res); } catch (WriteConcernException e) { @@ -767,6 +768,7 @@ public void testWriteConcernExceptionOnUpdate() throws UnknownHostException { ObjectId id = new ObjectId(); collection.insert(new BasicDBObject("_id", id)); try { + @SuppressWarnings("deprecation") WriteResult res = collection.update(new BasicDBObject("_id", id), new BasicDBObject("$set", new BasicDBObject("x", 1)), false, false, new WriteConcern(5).withWTimeout(1, MILLISECONDS)); fail("Write should have failed but succeeded with result " + res); @@ -778,6 +780,7 @@ public void testWriteConcernExceptionOnUpdate() throws UnknownHostException { } @Test + @SuppressWarnings("deprecation") //writeConcern public void testWriteConcernExceptionOnFindAndModify() throws UnknownHostException { assumeThat(serverVersionAtLeast(3, 2), is(true)); assumeThat(isDiscoverableReplicaSet(), is(true)); @@ -835,6 +838,7 @@ public void testWriteConcernExceptionOnFindAndModify() throws UnknownHostExcepti } @Test + @SuppressWarnings("deprecation") //writeConcern public void testWriteConcernExceptionOnUpsert() throws UnknownHostException { assumeThat(isDiscoverableReplicaSet(), is(true)); ObjectId id = new ObjectId(); @@ -850,6 +854,7 @@ public void testWriteConcernExceptionOnUpsert() throws UnknownHostException { } @Test + @SuppressWarnings("deprecation") public void testWriteConcernExceptionOnRemove() throws UnknownHostException { assumeThat(isDiscoverableReplicaSet(), is(true)); try { @@ -862,6 +867,7 @@ public void testWriteConcernExceptionOnRemove() throws UnknownHostException { } @Test + @SuppressWarnings("deprecation") //writeConcern public void testBulkWriteConcernException() throws UnknownHostException { assumeThat(isDiscoverableReplicaSet(), is(true)); try { 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 f55bec16eb1..16c3d31c150 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 @@ -59,7 +59,8 @@ public interface AggregatePublisher extends Publisher { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time 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 efafcb1c264..f59eb0dfa38 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 @@ -56,7 +56,8 @@ public interface DistinctPublisher extends Publisher { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time 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 888a439774f..90d8111896a 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 @@ -85,7 +85,8 @@ public interface FindPublisher extends Publisher { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionNamesPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionNamesPublisher.java index e4fa49cfede..9fa00167f91 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionNamesPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionNamesPublisher.java @@ -54,7 +54,8 @@ public interface ListCollectionNamesPublisher extends Publisher { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionsPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionsPublisher.java index e114e714de2..5b135e852fc 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionsPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListCollectionsPublisher.java @@ -16,6 +16,7 @@ package com.mongodb.reactivestreams.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -48,8 +49,22 @@ public interface ListCollectionsPublisher extends Publisher { * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListCollectionsPublisher maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListDatabasesPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListDatabasesPublisher.java index 5853f30d8ff..8a539da20bc 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListDatabasesPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListDatabasesPublisher.java @@ -17,6 +17,7 @@ package com.mongodb.reactivestreams.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -39,8 +40,22 @@ public interface ListDatabasesPublisher extends Publisher { * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListDatabasesPublisher maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListIndexesPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListIndexesPublisher.java index e4ac214063f..ab1a045e3f7 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListIndexesPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ListIndexesPublisher.java @@ -16,6 +16,7 @@ package com.mongodb.reactivestreams.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -37,8 +38,22 @@ public interface ListIndexesPublisher extends Publisher { * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListIndexesPublisher maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MapReducePublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MapReducePublisher.java index 7f7033a723b..a73fdf50e58 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MapReducePublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MapReducePublisher.java @@ -17,6 +17,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; @@ -116,7 +117,21 @@ public interface MapReducePublisher 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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 MapReducePublisher maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/gridfs/GridFSFindPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/gridfs/GridFSFindPublisher.java index 75f7a7cac10..8482b7f7c9c 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/gridfs/GridFSFindPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/gridfs/GridFSFindPublisher.java @@ -16,9 +16,12 @@ package com.mongodb.reactivestreams.client.gridfs; +import com.mongodb.MongoClientSettings; import com.mongodb.client.gridfs.model.GridFSFile; import com.mongodb.client.model.Collation; import com.mongodb.lang.Nullable; +import com.mongodb.reactivestreams.client.MongoCollection; +import com.mongodb.reactivestreams.client.MongoDatabase; import org.bson.conversions.Bson; import org.reactivestreams.Publisher; @@ -98,7 +101,21 @@ public interface GridFSFindPublisher 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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 GridFSFindPublisher maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImpl.java index 057a8067ad3..850073c60ef 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImpl.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImpl.java @@ -52,6 +52,7 @@ final class ListCollectionsPublisherImpl extends BatchCursorPublisher impl this.collectionNamesOnly = collectionNamesOnly; } + @SuppressWarnings("deprecation") public ListCollectionsPublisher maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImpl.java index b897a8bf9df..635af5ffb04 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImpl.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImpl.java @@ -48,6 +48,7 @@ final class ListDatabasesPublisherImpl extends BatchCursorPublisher implem super(clientSession, mongoOperationPublisher); } + @SuppressWarnings("deprecation") public ListDatabasesPublisher maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImpl.java index 79e5ce2a14a..be91f2db234 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImpl.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImpl.java @@ -44,6 +44,7 @@ final class ListIndexesPublisherImpl extends BatchCursorPublisher implemen super(clientSession, mongoOperationPublisher); } + @SuppressWarnings("deprecation") public ListIndexesPublisher maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/KeyManagementService.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/KeyManagementService.java index 0944007fba5..114192c9a31 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/KeyManagementService.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/crypt/KeyManagementService.java @@ -69,6 +69,7 @@ public void close() { tlsChannelStreamFactoryFactory.close(); } + @SuppressWarnings("deprecation") //readTimeout Mono decryptKey(final MongoKeyDecryptor keyDecryptor, @Nullable final Timeout operationTimeout) { SocketSettings socketSettings = SocketSettings.builder() .connectTimeout(timeoutMillis, MILLISECONDS) @@ -159,6 +160,7 @@ private static void handleError(final Throwable t, final OperationContext operat } } + @SuppressWarnings("deprecation") //readTimeout private OperationContext createOperationContext(@Nullable final Timeout operationTimeout, final SocketSettings socketSettings) { return OperationContext.simpleOperationContext(new TimeoutContext( new TimeoutSettings( diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncGridFSFindIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncGridFSFindIterable.java index 1021e6bc102..8c18763fb0b 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncGridFSFindIterable.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncGridFSFindIterable.java @@ -52,6 +52,7 @@ public GridFSFindIterable skip(final int skip) { } @Override + @SuppressWarnings("deprecation") public GridFSFindIterable 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/SyncListCollectionsIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListCollectionsIterable.java index 48d88963077..390f5ac22f9 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListCollectionsIterable.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListCollectionsIterable.java @@ -40,6 +40,7 @@ public ListCollectionsIterable filter(@Nullable final Bson filter) { } @Override + @SuppressWarnings("deprecation") public ListCollectionsIterable 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/SyncListDatabasesIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListDatabasesIterable.java index 4248e59c361..6379ec5323b 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListDatabasesIterable.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListDatabasesIterable.java @@ -34,6 +34,7 @@ class SyncListDatabasesIterable extends SyncMongoIterable implements ListD } @Override + @SuppressWarnings("deprecation") public ListDatabasesIterable 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/SyncListIndexesIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListIndexesIterable.java index 947cb8f0d0f..67a00672f2c 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListIndexesIterable.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListIndexesIterable.java @@ -32,6 +32,7 @@ class SyncListIndexesIterable extends SyncMongoIterable implements ListInd } @Override + @Deprecated public ListIndexesIterable 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/SyncListSearchIndexesIterable.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListSearchIndexesIterable.java index f119c645916..5e503c8b9a3 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListSearchIndexesIterable.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncListSearchIndexesIterable.java @@ -40,6 +40,7 @@ final class SyncListSearchIndexesIterable extends SyncMongoIterable implem } @Override + @Deprecated public ListSearchIndexesIterable 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/ListCollectionsPublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImplTest.java index a632edbae82..be0f6a146ef 100644 --- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImplTest.java +++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListCollectionsPublisherImplTest.java @@ -37,6 +37,7 @@ public class ListCollectionsPublisherImplTest extends TestHelper { @DisplayName("Should build the expected ListCollectionsOperation") @Test + @SuppressWarnings("deprecation") void shouldBuildTheExpectedOperation() { TestOperationExecutor executor = createOperationExecutor(asList(getBatchCursor(), getBatchCursor())); ListCollectionsPublisher publisher = new ListCollectionsPublisherImpl<>(null, createMongoOperationPublisher(executor) diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImplTest.java index c19a56f14cc..56340014b92 100644 --- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImplTest.java +++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListDatabasesPublisherImplTest.java @@ -35,6 +35,7 @@ public class ListDatabasesPublisherImplTest extends TestHelper { @DisplayName("Should build the expected ListDatabasesOperation") @Test + @SuppressWarnings("deprecation") void shouldBuildTheExpectedOperation() { configureBatchCursor(); diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImplTest.java index 5ae221b8a02..03f13cba5f5 100644 --- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImplTest.java +++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/ListIndexesPublisherImplTest.java @@ -36,6 +36,7 @@ public class ListIndexesPublisherImplTest extends TestHelper { @DisplayName("Should build the expected ListIndexesOperation") @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 bfa3e1a29ab..62a526d2e85 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 @@ -437,6 +437,7 @@ public void testDrop() { } @Test + @SuppressWarnings("deprecation") //maxTime public void testDropIndex() { String indexName = "index_name"; Bson index = Indexes.ascending("ascending_index"); @@ -496,6 +497,7 @@ public void testDropIndex() { } @Test + @SuppressWarnings("deprecation") //maxTime public void testDropIndexes() { DropIndexOptions options = new DropIndexOptions().maxTime(1, TimeUnit.MILLISECONDS); assertAll("dropIndexes", 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 f2fedd553dd..56f55bb25ed 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/AggregateObservable.scala @@ -62,7 +62,8 @@ case class AggregateObservable[TResult](private val wrapped: AggregatePublisher[ * - [[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]] + * - [[org.mongodb.scala.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] * * 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. 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 cc40841737a..749f335e4da 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/DistinctObservable.scala @@ -45,7 +45,8 @@ case class DistinctObservable[TResult](private val wrapped: DistinctPublisher[TR * - [[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]] + * - [[org.mongodb.scala.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] * * 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. 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 4fcfb40f38b..d4108e2b751 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala @@ -93,7 +93,8 @@ case class FindObservable[TResult](private val wrapped: FindPublisher[TResult]) * - [[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]] + * - [[org.mongodb.scala.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] * * 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. diff --git a/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionNamesObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionNamesObservable.scala index 0ced9f238bb..f6aba5211f0 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionNamesObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionNamesObservable.scala @@ -55,7 +55,8 @@ case class ListCollectionNamesObservable(wrapped: ListCollectionNamesPublisher) * - [[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]] + * - [[org.mongodb.scala.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] * * 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. diff --git a/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionsObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionsObservable.scala index 553f73a069a..758fef63ff1 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionsObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/ListCollectionsObservable.scala @@ -48,9 +48,21 @@ case class ListCollectionsObservable[TResult](wrapped: ListCollectionsPublisher[ * 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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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): ListCollectionsObservable[TResult] = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) this diff --git a/driver-scala/src/main/scala/org/mongodb/scala/ListDatabasesObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/ListDatabasesObservable.scala index 225c3c1d84e..01f0373787c 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/ListDatabasesObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/ListDatabasesObservable.scala @@ -36,9 +36,21 @@ case class ListDatabasesObservable[TResult](wrapped: ListDatabasesPublisher[TRes * 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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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): ListDatabasesObservable[TResult] = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) this diff --git a/driver-scala/src/main/scala/org/mongodb/scala/ListIndexesObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/ListIndexesObservable.scala index e17be7b1457..603d6661be0 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/ListIndexesObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/ListIndexesObservable.scala @@ -35,9 +35,21 @@ case class ListIndexesObservable[TResult](wrapped: ListIndexesPublisher[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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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): ListIndexesObservable[TResult] = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) this diff --git a/driver-scala/src/main/scala/org/mongodb/scala/ListSearchIndexesObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/ListSearchIndexesObservable.scala index ef4907d60b3..add16daaa69 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/ListSearchIndexesObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/ListSearchIndexesObservable.scala @@ -62,10 +62,22 @@ case class ListSearchIndexesObservable[TResult](wrapped: ListSearchIndexesPublis /** * Sets the maximum execution time on the server for this operation. * - * @param duration the duration. - * @return this. - * @see [[https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/ Max Time]] + * [[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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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): ListSearchIndexesObservable[TResult] = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) this diff --git a/driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala index e7c8ff67de3..f73d48aa042 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/MapReduceObservable.scala @@ -138,8 +138,19 @@ case class MapReduceObservable[TResult](wrapped: MapReducePublisher[TResult]) ex * 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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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. */ def maxTime(duration: Duration): MapReduceObservable[TResult] = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) diff --git a/driver-scala/src/main/scala/org/mongodb/scala/gridfs/GridFSFindObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/gridfs/GridFSFindObservable.scala index fdbea9add70..13834a6fbc4 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/gridfs/GridFSFindObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/gridfs/GridFSFindObservable.scala @@ -100,10 +100,22 @@ case class GridFSFindObservable(private val wrapped: GridFSFindPublisher) extend /** * Sets the maximum execution time on the server for this operation. * - * @see [[https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/ Max Time]] + * [[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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * 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): GridFSFindObservable = { wrapped.maxTime(duration.toMillis, TimeUnit.MILLISECONDS) this diff --git a/driver-scala/src/main/scala/org/mongodb/scala/internal/WriteConcernImplicits.scala b/driver-scala/src/main/scala/org/mongodb/scala/internal/WriteConcernImplicits.scala index 19d3769240d..6dbb4ddc0f4 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/internal/WriteConcernImplicits.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/internal/WriteConcernImplicits.scala @@ -33,7 +33,18 @@ private[scala] trait WriteConcernImplicits { * * @param wTimeout the wTimeout, which must be >= 0 and <= Integer.MAX_VALUE after conversion to milliseconds * @return the WriteConcern with the given wTimeout + * @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.ClientSessionOptions]] + * - [[org.mongodb.scala.TransactionOptions]] + * + * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this wTimeout + * irrelevant. If no timeout is specified at these levels, the wTimeout will be used. */ + @deprecated def withWTimeout(wTimeout: Duration): WriteConcern = jWriteConcern.withWTimeout(wTimeout.toMillis, TimeUnit.MILLISECONDS) } diff --git a/driver-sync/src/examples/documentation/CausalConsistencyExamples.java b/driver-sync/src/examples/documentation/CausalConsistencyExamples.java index 5435523e65a..30717442489 100644 --- a/driver-sync/src/examples/documentation/CausalConsistencyExamples.java +++ b/driver-sync/src/examples/documentation/CausalConsistencyExamples.java @@ -41,6 +41,7 @@ public final class CausalConsistencyExamples { * * @param args takes an optional single argument for the connection string */ + @SuppressWarnings("deprecation") public static void main(final String[] args) { setupDatabase(); MongoClient client = MongoClients.create(); diff --git a/driver-sync/src/main/com/mongodb/client/AggregateIterable.java b/driver-sync/src/main/com/mongodb/client/AggregateIterable.java index cf8a3be2474..0ed775054fa 100644 --- a/driver-sync/src/main/com/mongodb/client/AggregateIterable.java +++ b/driver-sync/src/main/com/mongodb/client/AggregateIterable.java @@ -102,7 +102,8 @@ public interface AggregateIterable extends MongoIterable { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-sync/src/main/com/mongodb/client/DistinctIterable.java b/driver-sync/src/main/com/mongodb/client/DistinctIterable.java index 07ec37e8ee2..d95e48c7a6a 100644 --- a/driver-sync/src/main/com/mongodb/client/DistinctIterable.java +++ b/driver-sync/src/main/com/mongodb/client/DistinctIterable.java @@ -55,7 +55,8 @@ public interface DistinctIterable extends MongoIterable { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-sync/src/main/com/mongodb/client/FindIterable.java b/driver-sync/src/main/com/mongodb/client/FindIterable.java index ecc03e33605..fbf97460c15 100644 --- a/driver-sync/src/main/com/mongodb/client/FindIterable.java +++ b/driver-sync/src/main/com/mongodb/client/FindIterable.java @@ -77,7 +77,8 @@ public interface FindIterable extends MongoIterable { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-sync/src/main/com/mongodb/client/ListCollectionNamesIterable.java b/driver-sync/src/main/com/mongodb/client/ListCollectionNamesIterable.java index a9547128e76..be0ee189c95 100644 --- a/driver-sync/src/main/com/mongodb/client/ListCollectionNamesIterable.java +++ b/driver-sync/src/main/com/mongodb/client/ListCollectionNamesIterable.java @@ -52,7 +52,8 @@ public interface ListCollectionNamesIterable extends MongoIterable { *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • - *
  • {@link ClientSession}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • * * * When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time diff --git a/driver-sync/src/main/com/mongodb/client/ListCollectionsIterable.java b/driver-sync/src/main/com/mongodb/client/ListCollectionsIterable.java index 6e7b7284f83..2348241e594 100644 --- a/driver-sync/src/main/com/mongodb/client/ListCollectionsIterable.java +++ b/driver-sync/src/main/com/mongodb/client/ListCollectionsIterable.java @@ -16,6 +16,7 @@ package com.mongodb.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -47,8 +48,22 @@ public interface ListCollectionsIterable extends MongoIterable * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListCollectionsIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/ListDatabasesIterable.java b/driver-sync/src/main/com/mongodb/client/ListDatabasesIterable.java index 0bd4693279d..f73babb9502 100644 --- a/driver-sync/src/main/com/mongodb/client/ListDatabasesIterable.java +++ b/driver-sync/src/main/com/mongodb/client/ListDatabasesIterable.java @@ -16,6 +16,7 @@ package com.mongodb.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -37,8 +38,22 @@ public interface ListDatabasesIterable extends MongoIterable { * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListDatabasesIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/ListIndexesIterable.java b/driver-sync/src/main/com/mongodb/client/ListIndexesIterable.java index 34551441131..bb14743950a 100644 --- a/driver-sync/src/main/com/mongodb/client/ListIndexesIterable.java +++ b/driver-sync/src/main/com/mongodb/client/ListIndexesIterable.java @@ -16,6 +16,7 @@ package com.mongodb.client; +import com.mongodb.MongoClientSettings; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.lang.Nullable; import org.bson.BsonValue; @@ -36,8 +37,22 @@ public interface ListIndexesIterable extends MongoIterable { * @param maxTime the max time * @param timeUnit the time unit, which may not be null * @return this - * @mongodb.driver.manual reference/operator/meta/maxTimeMS/ Max Time + * @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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 ListIndexesIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/ListSearchIndexesIterable.java b/driver-sync/src/main/com/mongodb/client/ListSearchIndexesIterable.java index 2aa82ea3fd6..bbf5af9c52c 100644 --- a/driver-sync/src/main/com/mongodb/client/ListSearchIndexesIterable.java +++ b/driver-sync/src/main/com/mongodb/client/ListSearchIndexesIterable.java @@ -17,6 +17,7 @@ package com.mongodb.client; import com.mongodb.ExplainVerbosity; +import com.mongodb.MongoClientSettings; import com.mongodb.annotations.Evolving; import com.mongodb.client.cursor.TimeoutMode; import com.mongodb.client.model.Collation; @@ -66,11 +67,25 @@ public interface ListSearchIndexesIterable extends MongoIterable + *
  • {@link MongoClientSettings.Builder#timeout(long, TimeUnit)}
  • + *
  • {@link MongoDatabase#withTimeout(long, TimeUnit)}
  • + *
  • {@link MongoCollection#withTimeout(long, TimeUnit)}
  • + *
  • {@link com.mongodb.ClientSessionOptions}
  • + *
  • {@link com.mongodb.TransactionOptions}
  • + * + * + * 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 ListSearchIndexesIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/MapReduceIterable.java b/driver-sync/src/main/com/mongodb/client/MapReduceIterable.java index 0b28fde91ee..9a07e356cd6 100644 --- a/driver-sync/src/main/com/mongodb/client/MapReduceIterable.java +++ b/driver-sync/src/main/com/mongodb/client/MapReduceIterable.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; @@ -127,7 +128,21 @@ public interface MapReduceIterable 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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 MapReduceIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterable.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterable.java index 9b8cb8b9117..a3df237a132 100644 --- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterable.java +++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSFindIterable.java @@ -16,6 +16,9 @@ package com.mongodb.client.gridfs; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; import com.mongodb.client.MongoIterable; import com.mongodb.client.gridfs.model.GridFSFile; import com.mongodb.client.model.Collation; @@ -92,7 +95,21 @@ public interface GridFSFindIterable 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 com.mongodb.ClientSessionOptions}
    • + *
    • {@link com.mongodb.TransactionOptions}
    • + *
    + * + * 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 GridFSFindIterable maxTime(long maxTime, TimeUnit timeUnit); /** diff --git a/driver-sync/src/main/com/mongodb/client/internal/ListCollectionsIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/ListCollectionsIterableImpl.java index 7d617947077..1f9e7f2da47 100644 --- a/driver-sync/src/main/com/mongodb/client/internal/ListCollectionsIterableImpl.java +++ b/driver-sync/src/main/com/mongodb/client/internal/ListCollectionsIterableImpl.java @@ -65,6 +65,7 @@ public ListCollectionsIterable filter(@Nullable final Bson filter) { } @Override + @SuppressWarnings("deprecation") public ListCollectionsIterable maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-sync/src/main/com/mongodb/client/internal/ListDatabasesIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/ListDatabasesIterableImpl.java index 83bc08b3dd1..9a6908393d4 100644 --- a/driver-sync/src/main/com/mongodb/client/internal/ListDatabasesIterableImpl.java +++ b/driver-sync/src/main/com/mongodb/client/internal/ListDatabasesIterableImpl.java @@ -59,6 +59,7 @@ public ListDatabasesIterableImpl(@Nullable final ClientSession clientSession, fi } @Override + @Deprecated public ListDatabasesIterable maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-sync/src/main/com/mongodb/client/internal/ListIndexesIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/ListIndexesIterableImpl.java index 19be1bdc8ed..42883232a0d 100644 --- a/driver-sync/src/main/com/mongodb/client/internal/ListIndexesIterableImpl.java +++ b/driver-sync/src/main/com/mongodb/client/internal/ListIndexesIterableImpl.java @@ -52,6 +52,7 @@ class ListIndexesIterableImpl extends MongoIterableImpl implem } @Override + @SuppressWarnings("deprecation") public ListIndexesIterable maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-sync/src/main/com/mongodb/client/internal/ListSearchIndexesIterableImpl.java b/driver-sync/src/main/com/mongodb/client/internal/ListSearchIndexesIterableImpl.java index c67106d357d..e1974381c07 100644 --- a/driver-sync/src/main/com/mongodb/client/internal/ListSearchIndexesIterableImpl.java +++ b/driver-sync/src/main/com/mongodb/client/internal/ListSearchIndexesIterableImpl.java @@ -87,6 +87,7 @@ public ListSearchIndexesIterable timeoutMode(final TimeoutMode timeoutM } @Override + @SuppressWarnings("deprecation") public ListSearchIndexesIterable maxTime(final long maxTime, final TimeUnit timeUnit) { notNull("timeUnit", timeUnit); this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit); diff --git a/driver-sync/src/test/functional/com/mongodb/client/AbstractRetryableReadsTest.java b/driver-sync/src/test/functional/com/mongodb/client/AbstractRetryableReadsTest.java index 34620130a40..e2f1e58c69f 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/AbstractRetryableReadsTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/AbstractRetryableReadsTest.java @@ -113,6 +113,7 @@ protected BsonDocument getDefinition() { } @Before + @SuppressWarnings("deprecation") //maxTimeMS public void setUp() { assumeFalse(skipTest); assumeTrue("Skipping test: " + definition.getString("skipReason", new BsonString("")).getValue(), diff --git a/driver-sync/src/test/functional/com/mongodb/client/Fixture.java b/driver-sync/src/test/functional/com/mongodb/client/Fixture.java index 3b0d45dca88..ab25de05560 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/Fixture.java +++ b/driver-sync/src/test/functional/com/mongodb/client/Fixture.java @@ -93,6 +93,7 @@ public static MongoClientSettings.Builder getMultiMongosMongoClientSettingsBuild return getMongoClientSettings(requireNonNull(getMultiMongosConnectionString())); } + @SuppressWarnings("deprecation") //readTimeout public static MongoClientSettings.Builder getMongoClientSettings(final ConnectionString connectionString) { MongoClientSettings.Builder builder = MongoClientSettings.builder() .applyConnectionString(connectionString) 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 924b96b7151..3d6dcf78608 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java +++ b/driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java @@ -1315,6 +1315,7 @@ ReadPreference getReadPreference(final BsonDocument arguments) { arguments.getDocument("readPreference").getString("mode").getValue()); } + @SuppressWarnings("deprecation") //wTimeoutMS WriteConcern getWriteConcern(final BsonDocument arguments) { WriteConcern writeConcern = WriteConcern.ACKNOWLEDGED; BsonDocument writeConcernDocument = arguments.getDocument("writeConcern"); diff --git a/driver-sync/src/test/functional/com/mongodb/client/ReadConcernTest.java b/driver-sync/src/test/functional/com/mongodb/client/ReadConcernTest.java index a40b258ea6c..8f22d15cafd 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ReadConcernTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/ReadConcernTest.java @@ -41,6 +41,7 @@ public class ReadConcernTest { private TestCommandListener commandListener; @Before + @SuppressWarnings("deprecation") public void setUp() { assumeTrue(canRunTests()); diff --git a/driver-sync/src/test/functional/com/mongodb/client/TransactionProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/TransactionProseTest.java index 5ea180b312d..c4d9e7fac23 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/TransactionProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/TransactionProseTest.java @@ -41,6 +41,7 @@ public class TransactionProseTest { private MongoCollection collection; @Before + @SuppressWarnings("deprecation") //readTimeout public void setUp() { assumeTrue(canRunTests()); MongoClientSettings.Builder builder = MongoClientSettings.builder() 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 415a019e9bc..2e035bf6a1f 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 @@ -361,6 +361,7 @@ private void initThread(final String id) { tasks.put(id, new ArrayList<>()); } + @SuppressWarnings("deprecation") //maxTimeMS & wTimeoutMS private void initClient(final BsonDocument entity, final String id, final Function mongoClientSupplier, final boolean waitForPoolAsyncWorkManagerStart) { 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 a36d17f0be5..4e4e612b32f 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 @@ -235,6 +235,7 @@ OperationResult executeListDatabaseNames(final BsonDocument operation) { new BsonArray(iterable.into(new ArrayList<>()).stream().map(BsonString::new).collect(toList()))); } + @SuppressWarnings("deprecation") //maxTimeMS OperationResult executeListCollections(final BsonDocument operation) { MongoDatabase database = getMongoDatabase(operation); BsonDocument arguments = operation.getDocument("arguments"); @@ -312,6 +313,7 @@ OperationResult executeListIndexNames(final BsonDocument operation) { }); } + @SuppressWarnings("deprecation") //maxTimeMS private ListIndexesIterable createListIndexesIterable(final BsonDocument operation) { MongoCollection collection = getMongoCollection(operation); BsonDocument arguments = operation.getDocument("arguments", new BsonDocument()); @@ -1525,6 +1527,7 @@ public OperationResult executeDropIndexes(final BsonDocument operation) { }); } + @SuppressWarnings("deprecation") //options.maxTime private static DropIndexOptions getDropIndexOptions(final BsonDocument arguments) { DropIndexOptions options = new DropIndexOptions(); for (Map.Entry cur : arguments.entrySet()) { diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedGridFSHelper.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedGridFSHelper.java index 13e95a58463..bbc7e6475c9 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedGridFSHelper.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedGridFSHelper.java @@ -228,6 +228,7 @@ private GridFSBucket getGridFsBucket(final BsonDocument operation) { return bucket; } + @SuppressWarnings("deprecation") //MaxTimeMS private GridFSFindIterable createGridFSFindIterable(final BsonDocument operation) { GridFSBucket bucket = getGridFsBucket(operation);