Skip to content

Add maxAdaptiveRetries API#1944

Draft
stIncMale wants to merge 3 commits intomongodb:backpressurefrom
stIncMale:backpressureMaxAdaptiveRetries
Draft

Add maxAdaptiveRetries API#1944
stIncMale wants to merge 3 commits intomongodb:backpressurefrom
stIncMale:backpressureMaxAdaptiveRetries

Conversation

@stIncMale
Copy link
Copy Markdown
Member

@stIncMale stIncMale commented Apr 17, 2026

The relevant specification from DRIVERS-3427

Search for maxAdaptiveRetries at

A concrete commit is specified instead of master because this is the last commit included in the DRIVERS-3160 Client Backpressure Support epic. Any newer commits are either irrelevant or are included in the DRIVERS-3337 Client Backpressure Improvements epic, which we do not care about for now.

AI usage

All modifications were done by the author. AI was used only to review the changes locally (Claude Code), and to review the GitHub PR (Copilot).

JAVA-6141

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the maxAdaptiveRetries configuration surface area (settings + connection string/URI parsing) per the client backpressure specification, along with related documentation updates for retry/error labels.

Changes:

  • Add maxAdaptiveRetries to MongoClientSettings, ConnectionString, and legacy MongoClientOptions/MongoClientURI, including equality/hash updates.
  • Parse/propagate the maxAdaptiveRetries URI option and add unit tests validating defaults and invalid values.
  • Improve/extend public docs for transaction and overload-related error labels across Java/Scala/Kotlin APIs.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
driver-core/src/main/com/mongodb/MongoClientSettings.java Adds maxAdaptiveRetries field + builder API + connection string application + equality/toString updates
driver-core/src/main/com/mongodb/ConnectionString.java Adds maxAdaptiveRetries option parsing, key registration, getter, and equality/hash updates
driver-core/src/main/com/mongodb/MongoException.java Updates error label documentation (transactions + overload/retryable labels)
driver-core/src/test/unit/com/mongodb/ConnectionStringUnitTest.java Adds coverage for maxAdaptiveRetries parsing, defaults, equals/hashCode
driver-core/src/test/unit/com/mongodb/AbstractConnectionStringTest.java Extends generic option validation to include maxAdaptiveRetries
driver-core/src/test/unit/com/mongodb/MongoClientSettingsSpecification.groovy Adds builder validation + propagation/default tests for maxAdaptiveRetries
driver-legacy/src/main/com/mongodb/MongoClientOptions.java Exposes maxAdaptiveRetries via legacy options getter/builder
driver-legacy/src/main/com/mongodb/MongoClientURI.java Documents and propagates maxAdaptiveRetries from URI to legacy builder
driver-legacy/src/test/unit/com/mongodb/MongoClientURISpecification.groovy Adds URI parsing/override/equality tests for maxAdaptiveRetries
driver-legacy/src/test/unit/com/mongodb/MongoClientOptionsSpecification.groovy Adds builder validation + default/null/0 tests for legacy options
driver-sync/src/main/com/mongodb/client/ClientSession.java Adds Javadoc @see pointers to transaction error labels
driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/ClientSession.java Adds Javadoc @see pointers to transaction error labels
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt Adds KDoc @see pointers to transaction error labels
driver-kotlin-coroutine/src/main/kotlin/com/mongodb/kotlin/client/coroutine/ClientSession.kt Adds KDoc @see pointers to transaction error labels
driver-scala/src/main/scala/org/mongodb/scala/package.scala Adds/extends Scala API docs/constants for overload/retryable error labels

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread driver-legacy/src/main/com/mongodb/MongoClientURI.java
Comment thread driver-sync/src/main/com/mongodb/client/ClientSession.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread driver-core/src/main/com/mongodb/MongoClientSettings.java
Comment on lines +46 to +63
@ParameterizedTest
@ValueSource(strings = {
"serverMonitoringMode=stream",
"maxAdaptiveRetries=42"
})
void equalAndHashCode(final String connectionStringOptions) {
ConnectionString default1 = new ConnectionString(DEFAULT_OPTIONS);
ConnectionString default2 = new ConnectionString(DEFAULT_OPTIONS);
String connectionString = DEFAULT_OPTIONS + connectionStringOptions;
ConnectionString actual1 = new ConnectionString(connectionString);
ConnectionString actual2 = new ConnectionString(connectionString);
assertAll(
() -> assertEquals(default1, default2),
() -> assertEquals(default1.hashCode(), default2.hashCode()),
() -> assertEquals(actual1, actual2),
() -> assertEquals(actual1.hashCode(), actual2.hashCode()),
() -> assertNotEquals(default1, actual1)
);
Copy link
Copy Markdown
Member Author

@stIncMale stIncMale Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I moved the equalAndHashCode so that it is near the defaults test, because both of these tests are not specific to any options. The rest of the tests in this file are option-specific.
  • I also modified the test a bit, so that we don't have to write DEFAULT_OPTIONS + each time we add a new element to ValueSource.strings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread driver-sync/src/main/com/mongodb/client/ClientSession.java Outdated
Comment thread driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread driver-core/src/main/com/mongodb/ConnectionString.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread driver-core/src/main/com/mongodb/ConnectionString.java Outdated
Comment thread driver-core/src/main/com/mongodb/ConnectionString.java Outdated
Comment thread driver-core/src/main/com/mongodb/MongoClientSettings.java
Comment thread driver-legacy/src/main/com/mongodb/MongoClientOptions.java
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


/**
* The codec registry to use, or null if not set.
* The codec registry to use.
Copy link
Copy Markdown
Member Author

@stIncMale stIncMale Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was found by me as a result of reacting to a not-directly-related AI comment: getCodecRegistry cannot return null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants