Skip to content

CSOT: Undeprecate timeout APIs #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/detekt/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<CurrentIssues>
<ID>IteratorNotThrowingNoSuchElementException:MongoCursor.kt$MongoCursor&lt;T : Any> : IteratorCloseable</ID>
<ID>LargeClass:MongoCollectionTest.kt$MongoCollectionTest</ID>
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues()</ID>
<ID>MaxLineLength:MapReduceFlow.kt$MapReduceFlow$*</ID>
<ID>MaxLineLength:MapReduceIterable.kt$MapReduceIterable$*</ID>
Expand Down
15 changes: 0 additions & 15 deletions driver-core/src/main/com/mongodb/ConnectionString.java
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@ 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) {
Expand Down Expand Up @@ -1592,21 +1591,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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;
Expand Down
2 changes: 0 additions & 2 deletions driver-core/src/main/com/mongodb/MongoClientSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ public static final class Builder {
private Builder() {
}

@SuppressWarnings("deprecation") //readTimeout
private Builder(final MongoClientSettings settings) {
notNull("settings", settings);
applicationName = settings.getApplicationName();
Expand Down Expand Up @@ -1116,7 +1115,6 @@ public String toString() {
+ '}';
}

@SuppressWarnings("deprecation") //readTimeout
private MongoClientSettings(final Builder builder) {
isTrue("timeoutMS > 0 ", builder.timeoutMS == null || builder.timeoutMS >= 0);
readPreference = builder.readPreference;
Expand Down
14 changes: 0 additions & 14 deletions driver-core/src/main/com/mongodb/TransactionOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,7 @@ public Builder readPreference(@Nullable final ReadPreference readPreference) {
* @return this
* @mongodb.server.release 4.2
* @since 3.11
*
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* <li>{@code TransactionOptions.Builder#timeout(long, TimeUnit)}</li>
* </ul>
*
* When executing a commit transaction operation, any explicitly set timeout at these levels takes precedence, rendering this
* commit time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
@Deprecated
public Builder maxCommitTime(@Nullable final Long maxCommitTime, final TimeUnit timeUnit) {
if (maxCommitTime == null) {
this.maxCommitTimeMS = null;
Expand Down
42 changes: 0 additions & 42 deletions driver-core/src/main/com/mongodb/WriteConcern.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,7 @@ public WriteConcern(final String w) {
* @param wTimeoutMS the wTimeout in milliseconds, which must be &gt;= 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
}
Expand Down Expand Up @@ -246,21 +232,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand Down Expand Up @@ -412,21 +384,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand Down
26 changes: 0 additions & 26 deletions driver-core/src/main/com/mongodb/client/model/CountOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,7 @@ public CountOptions skip(final int skip) {
*
* @param timeUnit the time unit to return the result in
* @return the maximum execution time in the given time unit
*
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* 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);
Expand All @@ -158,20 +145,7 @@ 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:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
@Deprecated
public CountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


import com.mongodb.CreateIndexCommitQuorum;
import com.mongodb.MongoClientSettings;
import com.mongodb.lang.Nullable;

import java.util.concurrent.TimeUnit;
Expand All @@ -40,21 +39,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand All @@ -66,21 +51,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.mongodb.client.model;


import com.mongodb.MongoClientSettings;

import java.util.concurrent.TimeUnit;

import static com.mongodb.assertions.Assertions.notNull;
Expand All @@ -37,20 +35,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand All @@ -62,20 +47,7 @@ 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:
*
* <ul>
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@link com.mongodb.ClientSessionOptions}</li>
* <li>{@link com.mongodb.TransactionOptions}</li>
* </ul>
*
* 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,7 @@ public class EstimatedDocumentCountOptions {
*
* @param timeUnit the time unit to return the result in
* @return the maximum execution time in the given time unit
*
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* 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);
Expand All @@ -64,20 +51,7 @@ 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:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
@Deprecated
public EstimatedDocumentCountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,7 @@ public FindOneAndDeleteOptions sort(@Nullable final Bson sort) {
* @param maxTime the max time
* @param timeUnit the time unit, which may not be null
* @return this
*
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
@Deprecated
public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
notNull("timeUnit", timeUnit);
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
Expand All @@ -121,20 +108,7 @@ public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUn
*
* @param timeUnit the time unit for the result
* @return the max time
*
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
*
* <ul>
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
* <li>{@code ClientSession}</li>
* </ul>
*
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
*/
@Deprecated
public long getMaxTime(final TimeUnit timeUnit) {
return timeUnit.convert(maxTimeMS, MILLISECONDS);
}
Expand Down
Loading