Skip to content
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 fun shouldCallTheUnderlyingMethods()</ID>
<ID>LongMethod:FindIterableTest.kt$FindIterableTest$@Test fun shouldCallTheUnderlyingMethods()</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:KotlinSerializerCodecTest.kt$KotlinSerializerCodecTest$@Test fun testDataClassOptionalBsonValues()</ID>
<ID>MaxLineLength:MapReduceFlow.kt$MapReduceFlow$*</ID>
<ID>MaxLineLength:MapReduceIterable.kt$MapReduceIterable$*</ID>
Expand Down
15 changes: 15 additions & 0 deletions driver-core/src/main/com/mongodb/ConnectionString.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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:
*
* <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: 2 additions & 0 deletions driver-core/src/main/com/mongodb/MongoClientSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
42 changes: 42 additions & 0 deletions driver-core/src/main/com/mongodb/WriteConcern.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,21 @@ 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 @@ -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:
*
* <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 @@ -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:
*
* <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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


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

import java.util.concurrent.TimeUnit;
Expand All @@ -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:
*
* <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 @@ -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:
*
* <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,6 +17,8 @@
package com.mongodb.client.model;


import com.mongodb.MongoClientSettings;

import java.util.concurrent.TimeUnit;

import static com.mongodb.assertions.Assertions.notNull;
Expand All @@ -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:
*
* <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 @@ -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:
*
* <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 @@ -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;
Expand Down Expand Up @@ -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:
*
* <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 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;
Expand Down Expand Up @@ -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:
*
* <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 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);
}
Expand Down
30 changes: 30 additions & 0 deletions driver-core/src/main/com/mongodb/connection/SocketSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
*
* <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 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;
Expand Down Expand Up @@ -161,6 +176,7 @@ public SocketSettings.Builder applyToProxySettings(final Block<ProxySettings.Bui
* @see com.mongodb.ConnectionString#getConnectTimeout()
* @see com.mongodb.ConnectionString#getSocketTimeout()
*/
@SuppressWarnings("deprecation") // connectionString.getSocketTimeout
public Builder applyConnectionString(final ConnectionString connectionString) {
Integer connectTimeout = connectionString.getConnectTimeout();
if (connectTimeout != null) {
Expand Down Expand Up @@ -202,7 +218,21 @@ public int getConnectTimeout(final TimeUnit timeUnit) {
* @param timeUnit the time unit to get the timeout in
* @return the read timeout in the requested time unit, or 0 if there is no timeout
* @see Builder#readTimeout(long, TimeUnit)
*
* @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 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public static List<String> createMongocryptdSpawnArgs(final Map<String, Object>
return spawnArgs;
}

@SuppressWarnings("deprecation") // builder.readTimeout
public static MongoClientSettings createMongocryptdClientSettings(@Nullable final String connectionString) {

return MongoClientSettings.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public InternalConnection get(final OperationContext operationContext) {
}

@Override
@SuppressWarnings("deprecation") //maxWaitTime
public void getAsync(final OperationContext operationContext, final SingleResultCallback<InternalConnection> callback) {
StartTime checkoutStart = connectionCheckoutStarted(operationContext);
Timeout maxWaitTimeout = checkoutStart.timeoutAfterOrInfiniteIfNegative(settings.getMaxWaitTime(NANOSECONDS), NANOSECONDS);
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ CommandCreator getCommandCreator() {
}

@Override
@SuppressWarnings("deprecation") //wTimeout
protected Function<BsonDocument, BsonDocument> getRetryCommandModifier() {
return command -> {
WriteConcern retryWriteConcern = getWriteConcern().withW("majority");
Expand Down
Loading