-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[JAVA-6060] Reduce global state by grouping internal settings #1864
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
base: main
Are you sure you want to change the base?
Conversation
…ntSettings configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request refactors internal MongoDB client configuration by replacing static global state with instance-based settings. The main change centralizes internal settings into a new InternalMongoClientSettings class that encapsulates both connection pool settings and the recordEverything flag, which was previously a static variable in InternalStreamConnection.
Changes:
- Introduced
InternalMongoClientSettingsclass to encapsulate internal configuration includingInternalConnectionPoolSettingsandrecordEverythingflag - Created
InternalMongoClientsfactory classes for both sync and reactive drivers to handle client creation with internal settings - Removed static
recordEverythingfield fromInternalStreamConnectionin favor of instance-based configuration - Updated test classes to use new factory methods and pass internal settings explicitly instead of relying on global state
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| driver-core/src/main/com/mongodb/internal/connection/InternalMongoClientSettings.java | New immutable settings class containing internal connection pool settings and recordEverything flag |
| driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnection.java | Removed static recordEverything field and added instance field; updated constructors to accept recordEverything parameter |
| driver-core/src/main/com/mongodb/internal/connection/InternalStreamConnectionFactory.java | Added recordEverything parameter to constructors and passed it to InternalStreamConnection |
| driver-core/src/main/com/mongodb/internal/connection/DefaultClusterFactory.java | Updated to use InternalMongoClientSettings instead of InternalConnectionPoolSettings |
| driver-core/src/main/com/mongodb/internal/connection/DefaultClusterableServerFactory.java | Replaced InternalConnectionPoolSettings parameter with InternalMongoClientSettings |
| driver-core/src/main/com/mongodb/internal/connection/LoadBalancedClusterableServerFactory.java | Replaced InternalConnectionPoolSettings parameter with InternalMongoClientSettings |
| driver-sync/src/main/com/mongodb/client/MongoClients.java | Refactored to delegate to InternalMongoClients with default internal settings |
| driver-sync/src/main/com/mongodb/client/internal/InternalMongoClients.java | New factory class for creating MongoClient instances with custom internal settings |
| driver-sync/src/main/com/mongodb/client/internal/Clusters.java | Added overload accepting InternalMongoClientSettings |
| driver-sync/src/main/com/mongodb/client/internal/MongoClientImpl.java | Removed createCluster and getStreamFactory helper methods (moved to InternalMongoClients) |
| driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/MongoClients.java | Refactored to delegate to InternalMongoClients with default internal settings |
| driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/InternalMongoClients.java | New factory class for creating reactive MongoClient instances with custom internal settings |
| driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java | Added createMongoClientWithInternalSettings method to support tests requiring internal settings |
| driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutProseTest.java | Implemented createMongoClientWithInternalSettings method |
| driver-sync/src/test/functional/com/mongodb/client/AbstractClientMetadataProseTest.java | Removed static recordEverything setup/teardown |
| driver-sync/src/test/functional/com/mongodb/client/ClientMetadataProseTest.java | Updated to use InternalMongoClients with recordEverything enabled |
| driver-sync/src/test/functional/com/mongodb/internal/connection/OidcAuthenticationProseTests.java | Updated to use InternalMongoClients with recordEverything enabled; removed static setup/teardown |
| driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java | Implemented createMongoClientWithInternalSettings method for reactive client |
| driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/AbstractClientMetadataProseTest.java | Updated to use InternalMongoClients with recordEverything enabled |
| driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/syncadapter/SyncMongoClient.java | Added constructor accepting reactive MongoClient for wrapping |
| driver-sync/src/test/unit/com/mongodb/client/internal/InternalMongoClientsTest.java | New unit tests for InternalMongoClients functionality |
| driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/InternalMongoClientsTest.java | New unit tests for reactive InternalMongoClients |
| driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java | Updated javadoc reference from static method to builder method |
| driver-core/src/test/functional/com/mongodb/internal/connection/SingleServerClusterTest.java | Updated to use InternalMongoClientSettings.getDefaults() |
| driver-core/src/test/functional/com/mongodb/internal/connection/CommandHelperSpecification.groovy | Updated to pass recordEverything parameter to InternalStreamConnectionFactory |
| driver-core/src/test/functional/com/mongodb/ClusterFixture.java | Updated to use InternalMongoClientSettings.getDefaults() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
driver-sync/src/test/unit/com/mongodb/client/internal/InternalMongoClientsTest.java
Outdated
Show resolved
Hide resolved
…MongoClientsTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
recordEverythingwith instance-basedInternalMongoClientSettingsconfiguration.InternalConnectionPoolSettingsunderInternalMongoClientSettingsFixes JAVA-6060