From 7572c56fd261be475266e0b7fe1a50fea26f8fb4 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Thu, 14 Aug 2025 18:03:01 -0700 Subject: [PATCH] Add Javadoc to specify that CSOT does not limit socket writes in synchronous API. JAVA-5569 --- .../main/com/mongodb/ClientEncryptionSettings.java | 13 +++++++++---- .../src/main/com/mongodb/ClientSessionOptions.java | 5 +++++ .../src/main/com/mongodb/MongoClientSettings.java | 3 +++ .../src/main/com/mongodb/TransactionOptions.java | 3 +++ driver-core/src/test/resources/specifications | 2 +- .../com/mongodb/kotlin/client/MongoCluster.kt | 6 ++++++ .../com/mongodb/kotlin/client/MongoCollection.kt | 6 ++++++ .../com/mongodb/kotlin/client/MongoDatabase.kt | 6 ++++++ .../src/main/com/mongodb/MongoClientOptions.java | 3 +++ .../src/main/com/mongodb/client/MongoCluster.java | 3 +++ .../main/com/mongodb/client/MongoCollection.java | 3 +++ .../src/main/com/mongodb/client/MongoDatabase.java | 3 +++ .../com/mongodb/client/gridfs/GridFSBucket.java | 6 ++++++ 13 files changed, 57 insertions(+), 5 deletions(-) diff --git a/driver-core/src/main/com/mongodb/ClientEncryptionSettings.java b/driver-core/src/main/com/mongodb/ClientEncryptionSettings.java index 6f0411d749..156ae3d6eb 100644 --- a/driver-core/src/main/com/mongodb/ClientEncryptionSettings.java +++ b/driver-core/src/main/com/mongodb/ClientEncryptionSettings.java @@ -172,10 +172,15 @@ public Builder keyExpiration(@Nullable final Long keyExpiration, final TimeUnit *
  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * - *

    Note: The timeout set through this method overrides the timeout defined in the key vault client settings - * specified in {@link #keyVaultMongoClientSettings(MongoClientSettings)}. - * Essentially, for operations that require accessing the key vault, the remaining timeout from the initial operation - * determines the duration allowed for key vault access.

    + *

    NOTE:

    + * * * @param timeout the timeout * @param timeUnit the time unit diff --git a/driver-core/src/main/com/mongodb/ClientSessionOptions.java b/driver-core/src/main/com/mongodb/ClientSessionOptions.java index 160d16c348..ec53457494 100644 --- a/driver-core/src/main/com/mongodb/ClientSessionOptions.java +++ b/driver-core/src/main/com/mongodb/ClientSessionOptions.java @@ -220,6 +220,11 @@ public Builder defaultTransactionOptions(final TransactionOptions defaultTransac *
  • {@code withTransaction}
  • *
  • {@code close}
  • * + * + *

    NOTE: When using synchronous API, this timeout does not limit socket writes, therefore + * there is a possibility that the operation might not be timed out when expected. This limitation does not + * apply to the reactive streams API. + * * @param defaultTimeout the timeout * @param timeUnit the time unit * @return this diff --git a/driver-core/src/main/com/mongodb/MongoClientSettings.java b/driver-core/src/main/com/mongodb/MongoClientSettings.java index 31206e5602..58c5599eab 100644 --- a/driver-core/src/main/com/mongodb/MongoClientSettings.java +++ b/driver-core/src/main/com/mongodb/MongoClientSettings.java @@ -699,6 +699,9 @@ public Builder inetAddressResolver(@Nullable final InetAddressResolver inetAddre *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: When using synchronous API, this timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. This limitation does not apply to the reactive streams API. + * * @param timeout the timeout * @param timeUnit the time unit * @return this diff --git a/driver-core/src/main/com/mongodb/TransactionOptions.java b/driver-core/src/main/com/mongodb/TransactionOptions.java index e5f22c22de..42fb6881e9 100644 --- a/driver-core/src/main/com/mongodb/TransactionOptions.java +++ b/driver-core/src/main/com/mongodb/TransactionOptions.java @@ -292,6 +292,9 @@ public Builder maxCommitTime(@Nullable final Long maxCommitTime, final TimeUnit *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: When using synchronous API, this timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. This limitation does not apply to the reactive streams API. + * * @param timeout the timeout * @param timeUnit the time unit * @return this diff --git a/driver-core/src/test/resources/specifications b/driver-core/src/test/resources/specifications index 48ce8ac56d..d5adadb2f5 160000 --- a/driver-core/src/test/resources/specifications +++ b/driver-core/src/test/resources/specifications @@ -1 +1 @@ -Subproject commit 48ce8ac56d481f611061dfabc8c0505c3fc7ef0d +Subproject commit d5adadb2f59ba5c598bc46bc93b0f1edbea9381c diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt index 1961989aaa..85ffc8fced 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCluster.kt @@ -78,6 +78,9 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * - `0` means infinite timeout. * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @return the optional timeout duration */ @Alpha(Reason.CLIENT) @@ -131,6 +134,9 @@ public open class MongoCluster protected constructor(private val wrapped: JMongo * - `0` means an infinite timeout * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit, defaults to Milliseconds * @return a new MongoCluster instance with the set time limit for operations 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 9521c50246..287924afc6 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 @@ -102,6 +102,9 @@ public class MongoCollection(private val wrapped: JMongoCollection) * - `0` means infinite timeout. * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @return the optional timeout duration * @since 5.2 */ @@ -176,6 +179,9 @@ public class MongoCollection(private val wrapped: JMongoCollection) * - `0` means an infinite timeout * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit, defaults to Milliseconds * @return a new MongoCollection instance with the set time limit for operations diff --git a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoDatabase.kt b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoDatabase.kt index d59ba62800..14fd89bdb2 100644 --- a/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoDatabase.kt +++ b/driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoDatabase.kt @@ -71,6 +71,9 @@ public class MongoDatabase(private val wrapped: JMongoDatabase) { * - `0` means infinite timeout. * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @return the optional timeout duration * @since 5.2 */ @@ -125,6 +128,9 @@ public class MongoDatabase(private val wrapped: JMongoDatabase) { * - `0` means an infinite timeout * - `> 0` The time limit to use for the full execution of an operation. * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit, defaults to Milliseconds * @return a new MongoDatabase instance with the set time limit for operations diff --git a/driver-legacy/src/main/com/mongodb/MongoClientOptions.java b/driver-legacy/src/main/com/mongodb/MongoClientOptions.java index 1f19fba348..59fe9753cb 100644 --- a/driver-legacy/src/main/com/mongodb/MongoClientOptions.java +++ b/driver-legacy/src/main/com/mongodb/MongoClientOptions.java @@ -1370,6 +1370,9 @@ public Builder srvServiceName(final String srvServiceName) { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    Note: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeoutMS the timeout in milliseconds * @return this * @since 5.2 diff --git a/driver-sync/src/main/com/mongodb/client/MongoCluster.java b/driver-sync/src/main/com/mongodb/client/MongoCluster.java index e86761f8d4..3da681d179 100644 --- a/driver-sync/src/main/com/mongodb/client/MongoCluster.java +++ b/driver-sync/src/main/com/mongodb/client/MongoCluster.java @@ -169,6 +169,9 @@ public interface MongoCluster { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit * @return a new MongoCluster instance with the set time limit for the full execution of an operation. diff --git a/driver-sync/src/main/com/mongodb/client/MongoCollection.java b/driver-sync/src/main/com/mongodb/client/MongoCollection.java index 0d3248b613..b58866f08a 100644 --- a/driver-sync/src/main/com/mongodb/client/MongoCollection.java +++ b/driver-sync/src/main/com/mongodb/client/MongoCollection.java @@ -204,6 +204,9 @@ public interface MongoCollection { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit * @return a new MongoCollection instance with the set time limit for the full execution of an operation diff --git a/driver-sync/src/main/com/mongodb/client/MongoDatabase.java b/driver-sync/src/main/com/mongodb/client/MongoDatabase.java index 1e84a91005..08a5d31793 100644 --- a/driver-sync/src/main/com/mongodb/client/MongoDatabase.java +++ b/driver-sync/src/main/com/mongodb/client/MongoDatabase.java @@ -160,6 +160,9 @@ public interface MongoDatabase { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit * @return a new MongoDatabase instance with the set time limit for the full execution of an operation. diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucket.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucket.java index 5335ed4ce9..6df1785594 100644 --- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucket.java +++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucket.java @@ -104,6 +104,9 @@ public interface GridFSBucket { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeUnit the time unit * @return the timeout in the given time unit * @since 4.x @@ -155,6 +158,9 @@ public interface GridFSBucket { *

  • {@code > 0} The time limit to use for the full execution of an operation.
  • * * + *

    NOTE: This timeout does not limit socket writes, therefore there is a possibility that the + * operation might not be timed out when expected. + * * @param timeout the timeout, which must be greater than or equal to 0 * @param timeUnit the time unit * @return a new GridFSBucket instance with the set time limit for the full execution of an operation