Skip to content

Commit ffc21e6

Browse files
authored
Undeprecate timeout APIs (#1369)
JAVA-5403
1 parent 4a15e31 commit ffc21e6

File tree

153 files changed

+29
-1109
lines changed

Some content is hidden

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

153 files changed

+29
-1109
lines changed

config/detekt/baseline.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<CurrentIssues>
55
<ID>IteratorNotThrowingNoSuchElementException:MongoCursor.kt$MongoCursor&lt;T : Any> : IteratorCloseable</ID>
66
<ID>LargeClass:MongoCollectionTest.kt$MongoCollectionTest</ID>
7-
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods()</ID>
8-
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test @Suppress("DEPRECATION") // maxTime fun shouldCallTheUnderlyingMethods()</ID>
7+
<ID>LongMethod:FindFlowTest.kt$FindFlowTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
8+
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods()</ID>
99
<ID>LongMethod:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues()</ID>
1010
<ID>MaxLineLength:MapReduceFlow.kt$MapReduceFlow$*</ID>
1111
<ID>MaxLineLength:MapReduceIterable.kt$MapReduceIterable$*</ID>

driver-core/src/main/com/mongodb/ConnectionString.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,6 @@ private ReadPreference buildReadPreference(@Nullable final String readPreference
10841084
}
10851085

10861086
@Nullable
1087-
@SuppressWarnings("deprecation") //wTimeout
10881087
private WriteConcern buildWriteConcern(@Nullable final Boolean safe, @Nullable final String w,
10891088
@Nullable final Integer wTimeout,
10901089
@Nullable final Boolean journal) {
@@ -1592,21 +1591,7 @@ public Integer getConnectTimeout() {
15921591
/**
15931592
* Gets the socket timeout specified in the connection string.
15941593
* @return the socket timeout
1595-
*
1596-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
1597-
*
1598-
* <ul>
1599-
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
1600-
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
1601-
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
1602-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
1603-
* <li>{@link com.mongodb.TransactionOptions}</li>
1604-
* </ul>
1605-
*
1606-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this socket timeout
1607-
* irrelevant. If no timeout is specified at these levels, the socket timeout will be used.
16081594
*/
1609-
@Deprecated
16101595
@Nullable
16111596
public Integer getSocketTimeout() {
16121597
return socketTimeout;

driver-core/src/main/com/mongodb/MongoClientSettings.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ public static final class Builder {
240240
private Builder() {
241241
}
242242

243-
@SuppressWarnings("deprecation") //readTimeout
244243
private Builder(final MongoClientSettings settings) {
245244
notNull("settings", settings);
246245
applicationName = settings.getApplicationName();
@@ -1116,7 +1115,6 @@ public String toString() {
11161115
+ '}';
11171116
}
11181117

1119-
@SuppressWarnings("deprecation") //readTimeout
11201118
private MongoClientSettings(final Builder builder) {
11211119
isTrue("timeoutMS > 0 ", builder.timeoutMS == null || builder.timeoutMS >= 0);
11221120
readPreference = builder.readPreference;

driver-core/src/main/com/mongodb/TransactionOptions.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,21 +258,7 @@ public Builder readPreference(@Nullable final ReadPreference readPreference) {
258258
* @return this
259259
* @mongodb.server.release 4.2
260260
* @since 3.11
261-
*
262-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
263-
*
264-
* <ul>
265-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
266-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
267-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
268-
* <li>{@code ClientSession}</li>
269-
* <li>{@code TransactionOptions.Builder#timeout(long, TimeUnit)}</li>
270-
* </ul>
271-
*
272-
* When executing a commit transaction operation, any explicitly set timeout at these levels takes precedence, rendering this
273-
* commit time irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
274261
*/
275-
@Deprecated
276262
public Builder maxCommitTime(@Nullable final Long maxCommitTime, final TimeUnit timeUnit) {
277263
if (maxCommitTime == null) {
278264
this.maxCommitTimeMS = null;

driver-core/src/main/com/mongodb/WriteConcern.java

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,7 @@ public WriteConcern(final String w) {
170170
* @param wTimeoutMS the wTimeout in milliseconds, which must be &gt;= 0
171171
* @mongodb.driver.manual reference/write-concern/#w-option w option
172172
* @mongodb.driver.manual reference/write-concern/#wtimeout wtimeout option
173-
*
174-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
175-
*
176-
* <ul>
177-
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
178-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
179-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
180-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
181-
* <li>{@link com.mongodb.TransactionOptions}</li>
182-
* </ul>
183-
*
184-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering wTimeoutMS irrelevant.
185-
* If no timeout is specified at these levels, the wTimeoutMS will be used.
186173
*/
187-
@Deprecated
188174
public WriteConcern(final int w, final int wTimeoutMS) {
189175
this(w, wTimeoutMS, null);
190176
}
@@ -246,21 +232,7 @@ public String getWString() {
246232
* @see #withWTimeout(long, TimeUnit)
247233
* @since 3.2
248234
* @mongodb.driver.manual core/write-concern/#timeouts wTimeout
249-
*
250-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
251-
*
252-
* <ul>
253-
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
254-
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
255-
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
256-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
257-
* <li>{@link com.mongodb.TransactionOptions}</li>
258-
* </ul>
259-
*
260-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this wTimeoutMS irrelevant.
261-
* If no timeout is specified at these levels, the wTimeoutMS will be used.
262235
*/
263-
@Deprecated
264236
@Nullable
265237
public Integer getWTimeout(final TimeUnit timeUnit) {
266238
notNull("timeUnit", timeUnit);
@@ -412,21 +384,7 @@ public WriteConcern withJournal(@Nullable final Boolean journal) {
412384
* @see #getWTimeout(TimeUnit)
413385
* @since 3.2
414386
* @mongodb.driver.manual reference/write-concern/#wtimeout wtimeout option
415-
*
416-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
417-
*
418-
* <ul>
419-
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
420-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
421-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
422-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
423-
* <li>{@link com.mongodb.TransactionOptions}</li>
424-
* </ul>
425-
*
426-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this wTimeoutMS irrelevant.
427-
* If no timeout is specified at these levels, the wTimeoutMS will be used.
428387
*/
429-
@Deprecated
430388
public WriteConcern withWTimeout(final long wTimeout, final TimeUnit timeUnit) {
431389
notNull("timeUnit", timeUnit);
432390
long newWTimeOutMS = TimeUnit.MILLISECONDS.convert(wTimeout, timeUnit);

driver-core/src/main/com/mongodb/client/model/CountOptions.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,7 @@ public CountOptions skip(final int skip) {
133133
*
134134
* @param timeUnit the time unit to return the result in
135135
* @return the maximum execution time in the given time unit
136-
*
137-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
138-
*
139-
* <ul>
140-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
141-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
142-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
143-
* <li>{@code ClientSession}</li>
144-
* </ul>
145-
*
146-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
147-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
148136
*/
149-
@Deprecated
150137
public long getMaxTime(final TimeUnit timeUnit) {
151138
notNull("timeUnit", timeUnit);
152139
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -158,20 +145,7 @@ public long getMaxTime(final TimeUnit timeUnit) {
158145
* @param maxTime the max time
159146
* @param timeUnit the time unit, which may not be null
160147
* @return this
161-
*
162-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
163-
*
164-
* <ul>
165-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
166-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
167-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
168-
* <li>{@code ClientSession}</li>
169-
* </ul>
170-
*
171-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
172-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
173148
*/
174-
@Deprecated
175149
public CountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
176150
notNull("timeUnit", timeUnit);
177151
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);

driver-core/src/main/com/mongodb/client/model/CreateIndexOptions.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
import com.mongodb.CreateIndexCommitQuorum;
21-
import com.mongodb.MongoClientSettings;
2221
import com.mongodb.lang.Nullable;
2322

2423
import java.util.concurrent.TimeUnit;
@@ -40,21 +39,7 @@ public class CreateIndexOptions {
4039
*
4140
* @param timeUnit the time unit to return the result in
4241
* @return the maximum execution time in the given time unit
43-
*
44-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
45-
*
46-
* <ul>
47-
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
48-
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
49-
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
50-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
51-
* <li>{@link com.mongodb.TransactionOptions}</li>
52-
* </ul>
53-
*
54-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
55-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
5642
*/
57-
@Deprecated
5843
public long getMaxTime(final TimeUnit timeUnit) {
5944
notNull("timeUnit", timeUnit);
6045
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -66,21 +51,7 @@ public long getMaxTime(final TimeUnit timeUnit) {
6651
* @param maxTime the max time
6752
* @param timeUnit the time unit, which may not be null
6853
* @return this
69-
*
70-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
71-
*
72-
* <ul>
73-
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
74-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
75-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
76-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
77-
* <li>{@link com.mongodb.TransactionOptions}</li>
78-
* </ul>
79-
*
80-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
81-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
8254
*/
83-
@Deprecated
8455
public CreateIndexOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
8556
notNull("timeUnit", timeUnit);
8657
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);

driver-core/src/main/com/mongodb/client/model/DropIndexOptions.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
package com.mongodb.client.model;
1818

1919

20-
import com.mongodb.MongoClientSettings;
21-
2220
import java.util.concurrent.TimeUnit;
2321

2422
import static com.mongodb.assertions.Assertions.notNull;
@@ -37,20 +35,7 @@ public class DropIndexOptions {
3735
*
3836
* @param timeUnit the time unit to return the result in
3937
* @return the maximum execution time in the given time unit
40-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
41-
*
42-
* <ul>
43-
* <li>{@link MongoClientSettings.Builder#getTimeout(TimeUnit)}</li>
44-
* <li>{@code MongoDatabase#getTimeout(TimeUnit)}</li>
45-
* <li>{@code MongoCollection#getTimeout(TimeUnit)}</li>
46-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
47-
* <li>{@link com.mongodb.TransactionOptions}</li>
48-
* </ul>
49-
*
50-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
51-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
5238
*/
53-
@Deprecated
5439
public long getMaxTime(final TimeUnit timeUnit) {
5540
notNull("timeUnit", timeUnit);
5641
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -62,20 +47,7 @@ public long getMaxTime(final TimeUnit timeUnit) {
6247
* @param maxTime the max time
6348
* @param timeUnit the time unit, which may not be null
6449
* @return this
65-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
66-
*
67-
* <ul>
68-
* <li>{@link MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
69-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
70-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
71-
* <li>{@link com.mongodb.ClientSessionOptions}</li>
72-
* <li>{@link com.mongodb.TransactionOptions}</li>
73-
* </ul>
74-
*
75-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
76-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
7750
*/
78-
@Deprecated
7951
public DropIndexOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
8052
notNull("timeUnit", timeUnit);
8153
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);

driver-core/src/main/com/mongodb/client/model/EstimatedDocumentCountOptions.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,7 @@ public class EstimatedDocumentCountOptions {
3939
*
4040
* @param timeUnit the time unit to return the result in
4141
* @return the maximum execution time in the given time unit
42-
*
43-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
44-
*
45-
* <ul>
46-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
47-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
48-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
49-
* <li>{@code ClientSession}</li>
50-
* </ul>
51-
*
52-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
53-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
5442
*/
55-
@Deprecated
5643
public long getMaxTime(final TimeUnit timeUnit) {
5744
notNull("timeUnit", timeUnit);
5845
return timeUnit.convert(maxTimeMS, TimeUnit.MILLISECONDS);
@@ -64,20 +51,7 @@ public long getMaxTime(final TimeUnit timeUnit) {
6451
* @param maxTime the max time
6552
* @param timeUnit the time unit, which may not be null
6653
* @return this
67-
*
68-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
69-
*
70-
* <ul>
71-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
72-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
73-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
74-
* <li>{@code ClientSession}</li>
75-
* </ul>
76-
*
77-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
78-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
7954
*/
80-
@Deprecated
8155
public EstimatedDocumentCountOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
8256
notNull("timeUnit", timeUnit);
8357
this.maxTimeMS = TimeUnit.MILLISECONDS.convert(maxTime, timeUnit);

driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,7 @@ public FindOneAndDeleteOptions sort(@Nullable final Bson sort) {
9696
* @param maxTime the max time
9797
* @param timeUnit the time unit, which may not be null
9898
* @return this
99-
*
100-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
101-
*
102-
* <ul>
103-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
104-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
105-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
106-
* <li>{@code ClientSession}</li>
107-
* </ul>
108-
*
109-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
110-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
11199
*/
112-
@Deprecated
113100
public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUnit) {
114101
notNull("timeUnit", timeUnit);
115102
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
@@ -121,20 +108,7 @@ public FindOneAndDeleteOptions maxTime(final long maxTime, final TimeUnit timeUn
121108
*
122109
* @param timeUnit the time unit for the result
123110
* @return the max time
124-
*
125-
* @deprecated Prefer using the operation execution timeout configuration options available at the following levels:
126-
*
127-
* <ul>
128-
* <li>{@code MongoClientSettings.Builder#timeout(long, TimeUnit)}</li>
129-
* <li>{@code MongoDatabase#withTimeout(long, TimeUnit)}</li>
130-
* <li>{@code MongoCollection#withTimeout(long, TimeUnit)}</li>
131-
* <li>{@code ClientSession}</li>
132-
* </ul>
133-
*
134-
* When executing an operation, any explicitly set timeout at these levels takes precedence, rendering this maximum execution time
135-
* irrelevant. If no timeout is specified at these levels, the maximum execution time will be used.
136111
*/
137-
@Deprecated
138112
public long getMaxTime(final TimeUnit timeUnit) {
139113
return timeUnit.convert(maxTimeMS, MILLISECONDS);
140114
}

0 commit comments

Comments
 (0)