Learn what's new in:
What's New in 5.6
The 5.6 driver release includes the following changes, fixes, and features:
- Adds experimental support for Queryable Encryption prefix, suffix, and substring queries. To learn more about QE, see In-Use Encryption. - Note- Experimental Feature- Queryable Encryption prefix, suffix, and substring queries are unstable, and their security is not guaranteed until they're generally available (GA). Use them in experimental workloads only. 
- Adds an - nsTypefield to- ChangeStreamDocumentobjects. This field contains the namespace type (- COLLECTION,- TIMESERIES, or- VIEW) of the change event.
- Adds client-side operation timeout (CSOT) support for OIDC authentication. 
- When - timeoutMSis set for CSOT, the driver ignores the value of the- maxWaitTimeconnection setting.
- Adds an - appendMetadata()method to the- MongoClientclass. You can use this method to append metadata to an existing client's metadata. The maximum metadata size is 512 MB.
- Adds a public constructor to the - RewrapManyDataKeyOptionsclass.
- Merges the - AsyncReadOperationand- AsyncWriteOperationinterfaces into the- ReadOperationand- WriteOperationinterfaces. You can create read and write operations by using builder methods in the- Operationsclass.
- Deprecates the - MongoNamespace.COMMAND_COLLECTION_NAMEconstant.
- Fixes a bug that prevented OIDC reauthentication within a session. 
- When serializing a POJO annotated with - @BsonDiscriminator, if the property's- readNamematches the discriminator key, the driver serializes the field only once.
- After you call the - next()or- tryNext()method on a- CommandCursorResultinstance, the driver clears the- CommandCursorResult.resultsproperty to free memory.
- The - PojoBuilderHelperclass creates property models that include properties from abstract classes and interfaces.
- The driver publishes and logs the following events when the cluster topology changes: - ClusterOpeningEvent: Published when the topology opens
- ClusterDescriptionChangedEvent: Published when the topology description changes
- ClusterClosedEvent: Published when the topology closes
 
- The driver throws a - MongoStalePrimaryExceptionwhen the primary replica set member becomes stale for one of the following reasons:- A new primary member is elected or discovered. 
- The value of the - electionIdor- setVersionfield in the primary member doesn't match the values of these fields in the other replica set members.
 - To learn more about replica sets, see Replication in the MongoDB Server manual. 
What's New in 5.5.1
The 5.5.1 driver patch release includes the following changes:
- Fixes an issue where OIDC reauthentication failed when triggered by an operation run in a session, including operations run in a transaction. 
What's New in 5.5
Important
Removal of Support for MongoDB Server 4.0
Java driver v5.5 removes support for MongoDB Server 4.0. To learn more about compatible versions of the server, see Compatibility.
The 5.5 driver release includes the following changes, fixes, and features:
- Introduces performance improvements that are reflected in the driver performance benchmarks. To view the results of the performance benchmark tests, see the following Performance Improvements section. 
Performance Improvements
The tables in this section show the results of performance tests for the synchronous Java driver. The tests were conducted on a MongoDB Server 8.0 deployment with the following configuration:
- Running on - localhostwith negligible network latency. In higher-latency environments, you might see less significant performance improvements.
- Authentication disabled. 
- TLS disabled. 
We expect similar performance increases for all MongoDB
Java drivers because they share the improved driver-core API.
Standard Transport Settings
The following table shows the results of performance tests for v5.5 of the driver configured with standard transport settings. Each row includes the feature tested, the percent improvement in performance, and the z-score.
| Feature | Percent Improvement | Z-score | 
|---|---|---|
| Deep BSON decoding | 19.44% | 5.4 | 
| Deep BSON encoding | 102% | 22.8 | 
| Find many and empty the cursor | 25.08% | 13.72 | 
| Find one by ID | 2.7% | 3.16 | 
| Flat BSON decoding | 31.2% | 9.38 | 
| Flat BSON encoding | 199.5% | 12.34 | 
| Full BSON decoding | 16.5% | 7.23 | 
| Full BSON encoding | 147.3% | 10.39 | 
| JSON-LD multi-file import | 21.8% | 8.21 | 
| Client bulk insert with large documents | 91.3% | 24.44 | 
| Collection bulk insert with large documents | 96.5% | 8.79 | 
| Bulk insert with large documents | 93.3% | 8.11 | 
| Bulk insert with small documents | 39.3% | 5.72 | 
| Insert one with large documents | 82.4% | 7.28 | 
| Client bulk insert with small documents | 49.5% | 17.99 | 
| Collection bulk insert with small documents | 47.8% | 6.44 | 
Netty Transport Settings
The following table shows the results of performance tests for v5.5 of the driver configured with Netty transport settings. Each row includes the feature tested, the percent improvement in performance, and the z-score.
| Feature | Percent Improvement | Z-score | 
|---|---|---|
| Find many and empty the cursor | 40.3% | 14.81 | 
| Find one by ID | 4.4% | 4.12 | 
| JSON-LD multi-file import | 16.9% | 3.77 | 
| Client bulk insert with large documents | 54.8% | 14.49 | 
| Collection bulk insert with large documents | 104.9% | 38.72 | 
| Bulk insert with large documents | 74.6% | 65.55 | 
| Insert one with large documents | 66.6% | 58.65 | 
| Client bulk insert with small documents | 36.1% | 15.41 | 
| Collection bulk insert with small documents | 39.3% | 37.38 | 
| Bulk insert with small documents | 35.1% | 41.51 | 
Tip
To learn more about how we conduct driver performance benchmark tests, see the Performance Benchmarking specification.
What's New in 5.4
The 5.4 driver release includes the following changes, fixes, and features:
- Supports - $lookupoperations for CSFLE and QE. To learn more, see the following references in the Server manual:- $lookup and $graphLookup Behavior for CSFLE 
 
- Introduces a Bill of Materials (BOM) to manage versions of MongoDB JVM artifacts that you might use in your application. To view instructions on adding the BOM to your application, see the Add the Java driver Bill of Materials step of the Get Started tutorial. 
- Updates AWS SDK dependencies to 2.30.31 and 1.12.782 for testing the - MONGODB-AWSauthentication mechanism.
- Adds a sort option to the - ClientUpdateOneOptionsand- ClientReplaceOneOptionsclasses. This change allows you to set a sort order for update and replace operations in client bulk writes. To learn more, see the Update Example and Replace Example sections of the Bulk Operations guide.
- Adds Kubernetes support for OIDC authentication. To learn more, see the Kubernetes section of the OIDC (Workload Identity Federation) guide. 
- Adds first class support for the following MongoDB Search query operators: - phrase
- regex
- queryString
- equals
- moreLikeThis
- in
- wildcard
 - To learn more, see the Create Pipeline Search Stages section of the MongoDB Search guide. 
- Updates cursors to refresh the - timeoutMSsetting when you call- close()without affecting the operation timeout.
- Enables you to use an index when calling the - distinct()method by specifying a- hintoption.
To view a full list of changes in this release, see the v5.4 release notes on GitHub.
What's New in 5.3
The 5.3 driver release includes the following changes, fixes, and features:
- Important: The next minor release will drop support for MongoDB Server version 4.0 and raise the minimum supported version to 4.2. We recommend making changes to your application to accommodate breaking changes. See the Release Notes section in the Server manual to learn more about upgrading. 
- Adds the - BinaryVectorclass to implement BSON Binary Subtype 9 for vector storage and retrieval. This class provides more effective storage of values compared a list of- Doubleinstances. You can create the following vector types based on the type of elements your vector contains:- Int8BinaryVector: Vector of 8-bit signed integers
- Float32BinaryVector: Vector of floating-point numbers
- PackedBitBinaryVector: Binary quantized vector (In beta and subject to change before becoming generally available)
 - To learn more about this feature, see Vector Quantization in the Atlas documentation. To learn about how to use this type when using the MongoDB Vector Search feature, see the MongoDB Vector Search guide. 
- Removes explicit fairness from the connection pool implementation. This change might contribute to better throughput when you use a - MongoClientinstance in many application threads. However, this change might cause increased tail latency.
- Adds a sort option to the - updateOne()and- replaceOne()methods. This change also allows you to set a sort as an option when creating- ReplaceOneModeland- UpdateOneModelinstances. To learn more, see the Update Documents and Bulk Write Operations guides.
- Adds a client bulk write API that allows you to perform write operations on multiple databases and collections at once. To learn more about this feature, see the Client Bulk Write section of the Bulk Operations guide. 
What's New in 5.2.1
The 5.2.1 driver patch release includes the following changes:
- Fixes an issue that caused applications built with Quarkus to throw a - java.lang.UnsatisfiedLinkErrorwhen initializing- libmongocryptbindings.
- Fixes an issue that caused the - mongodb-driver-corepackage to error when deployed to an OSGi runtime. The- Import-Package- org.mongodb:mongodb-driver-coremanifest attribute no longer requires the- com.oracle.svm.core.annotate.*packages.
What's New in 5.2
Important
Removal of Support for MongoDB Server 3.6
Java driver v5.2 removes support for MongoDB Server 3.6. To learn more about compatible versions of the server, see Compatibility.
The 5.2 driver release includes the following changes, fixes, and features:
- A forward-slash ( - /) character between the host names and client options in a connection URI is optional. The driver parses the following connection URI examples in the same way:- // Connection URI with delimiting forward-slash - String uri = "mongodb://example.com/?w=majority"; - // Connection URI without delimiting forward-slash - String uri = "mongodb://example.com?w=majority"; 
- Enables setting a client-side operations timeout (CSOT). This feature allows you to set a single timeout on your - MongoClientinstance that applies to all operations performed with that client. To learn more, see the Limit Server Execution Time guide.- Important- Deprecated Timeout Options- The following timeout options are deprecated: - waitQueueTimeoutMS
- socketTimeoutMS
- wTimeoutMS
- maxTimeMS
- maxCommitTimeMS
 - Use the CSOT feature to replace the functionality of these options. 
- Adds the - SearchIndexTypeclass, which you can pass when constructing a- SearchIndexModelinstance. This change allows you to specify the index type when creating an Atlas Search or Vector Search index. To learn more, see MongoDB Search and Vector Search Indexes in the Indexes guide.
- Delegates the implementation of the algorithms that implement the - SCRAM-SHA-1and- SCRAM-SHA-256authentication mechanisms to the configured JCA provider. This change means that your application can use a configured FIPS-compliant JCA provider to provide a higher level of security.
- Revises the mongodb-crypt dependency versioning to match the versioning for the JVM drivers. Future versions of - mongodb-cryptwill be released alongside the driver and will share the same version number. You must upgrade your- mongodb-cryptdependency to v5.2.0 when upgrading your driver for this release. To learn more, see the In-Use Encryption guide.
- Performance improvements due to implementation of native cryptography on all supported platforms. The following list describes the actions needed to implement this improvement depending on your operating system: - Windows: Upgrade your - mongodb-cryptversion to v5.2.0.
- Mac: Upgrade your - mongodb-cryptversion to v5.2.0.
- Linux: Install - libmongocrypt.sodirectly on the file system, instead of using the file that is bundled within the- mongodb-cryptJAR file. You can find Linux instructions to install- libmongocryptin the Server manual. If you use a package manager to install- libmongocrypt, Java Native Access (JNA) will find it there without further configuration. Alternatively, you can specify the search path by setting the- LD_LIBRARY_PATHenvironment variable to the file path of the- libmongocryptpackage.- We recommend direct installation because the bundled shared library does not link with OpenSSL due to the potential for OpenSSL binary incompatibilities. - The shared library loading is handled by JNA. You can view the rules for library loading search path order in the NativeLibrary class documentation. 
 
- Fixes an issue that caused the - InsertOneResult.getInsertedId()and- InsertManyResult.getInsertedIds()methods to return incorrect document IDs in some situations. This change is backported to Java driver v5.1.4 and v4.11.4.
- When a sharded cluster operation is unsuccessful, the driver avoids selecting the same - mongosserver for operation retry attempts if other- mongosservers are available.
- Adds reachability metadata needed when your application uses GraalVM Native Image. This metadata replaces the need for collecting reachability metadata when using the driver libraries. To learn more, see Reachability Metadata in the GraalVM documentation. - This change does not add the - libjnidispatchand- libmongocryptresource entries, because adding entries for all supported platforms (targets) significantly affects the size of native executables built using GraalVM Native Image. View this sample resource-config.json file in the driver GitHub repository to see how to specify these entries explicitly if your application depends on the- org.mongodb:mongodb-cryptlibrary.
- Enables exact vector search by extending the - VectorSearchOptionsAPI to introduce the following specific option subtypes:- ExactVectorSearchOptions: Use this options type to enable precise matching, ensuring that results are the closest vectors to a given query vector.
- ApproximateVectorSearchOptions: Use this options type to enable searches that might not return the exact closest vectors. You can pass a- numCandidatesparameter when instantiating this type to specify the number of nearest neighbors to consider.
 - To learn more about using the MongoDB Vector Search feature, see MongoDB Vector Search in the Aggregates Builders guide. 
What's New in 5.1.3
The 5.1.3 driver patch release includes the following changes:
What's New in 5.1.2
The 5.1.2 driver patch release includes the following changes:
- Fixes an issue that prevents the driver from encoding and decoding concrete classes that extend generic base classes, in cases that you specify the base class as the generic type of the - MongoCollectioninstance.
- Fixes an issue related to how domain names are validated when you use SOCKS5 proxy functionality, allowing you to use domain names with more than six characters in the top-level domain. 
What's New in 5.1.1
The 5.1.1 driver patch release includes the following changes:
- When using the - MONGODB-OIDCauthentication mechanism, you must not include comma characters in the- authMechanismPropertiesconnection string value. To learn more about this behavior, see the MONGODB-OIDC guide.
- Optimizes GridFS throughput by removing redundant byte array cloning. The - GridFSDownloadStreamand- GridFSUploadStreamtypes use the- BsonDocumenttype instead of- Document.
What's New in 5.1
Warning
Deprecations in this release
To avoid breaking changes in future major releases of the driver, replace any application code that depends on deprecated program elements.
This section includes the following information:
Deprecations in 5.1
- Support for MongoDB Server v3.6 is deprecated and will be removed in the next driver version release. To learn how to upgrade your MongoDB Server deployment, see Release Notes in the MongoDB Server manual. 
Improvements in 5.1
- Internal testing of GraalVM native image technology. These tests involve building native applications by using the GraalVM native-image tool. 
- Enhanced support for the MONGODB-OIDC authentication mechanism. For more information about OIDC, see the OIDC (Workload Identity Federation) guide. 
New Features in 5.1
- Introduces the - serverMonitoringModeconnection URI option. For more information about this option, see the Stable API guide.
What's New in 5.0
Warning
Breaking changes in this release
This driver version introduces breaking changes. For a list of these changes, see the Version 5.0 Breaking Changes section in the Upgrade guide.
Warning
Deprecations in this release
To avoid breaking changes in future major releases of the driver, replace any application code that depends on deprecated program elements.
This section includes the following information:
Deprecations in 5.0
- The - org.mongodb.scala.Observable.completeWithUnit()method is deprecated. This method is not useful anymore because the driver now exposes- org.mongodb.scala.Observable[Unit]instead of- org.mongodb.scala.Observable[Void]. This relates to a breaking change about Observables in this release.
Behavioral changes in 5.0
- The - getElapsedTime()method on- com.mongodb.event.ConnectionReadyEventincludes the time taken to deliver the- ConnectionCreatedEvent. That is, the time returned includes the duration of the- com.mongodb.event.ConnectionPoolListener.connectionCreated()method.- The - getElapsedTime()methods on- com.mongodb.event.ConnectionCheckedOutFailedEventand- com.mongodb.event.ConnectionCheckedOutEventinclude the time taken to deliver the- com.mongodb.event.ConnectionCheckOutStartedEvent. That is, the time returned includes the duration of the- com.mongodb.eventConnectionPoolListener.connectionCheckOutStarted()method.
New features in 5.0
The 5.0 driver release introduces the following features:
- Adds support for the - authorizedCollectionoption of the- listCollectionscommand. This was done by changing the- com.mongodb.client.MongoDatabase.listCollectionNames()methods. The return type is now- com.mongodb.client.ListCollectionNamesIterable, while previously it was a- MongoIterable<String>. This change allows the return value to be configured using the- ListCollectionNamesIterable.authorizedCollections()method and specifying the- authorizedCollectionsoption. Equivalent changes were made to following classes and interfaces:- com.mongodb.reactivestreams.client.MongoDatabase
- org.mongodb.scala.MongoDatabase
- com.mongodb.kotlin.client.MongoDatabase
- com.mongodb.kotlin.client.coroutine.MongoDatabase
 - These changes introduce a binary breaking change to the listCollectionsNames() method. For more information about the - MongoDatabase.listCollectionNames()method and the- authorizedCollectionsoption, see the listCollections Server manual page or Get a List of Collections.
Note
The v5.0.2 patch release fixed an issue related to how domain names are validated when you use SOCKS5 proxy functionality, allowing you to use domain names with more than six characters in the top-level domain.
What's New in 4.11
This section includes the following information:
Deprecations in 4.11
Warning
Deprecations in this release
To avoid breaking changes in future major releases of the driver, replace any application code that depends on deprecated methods and types.
The 4.11 driver release deprecates the following items:
- The - getStats()and- isCapped()instance methods of the- DBCollectionclass are deprecated. The corresponding server commands are deprecated in MongoDB v6.2 and later. Use the- $collStatsaggregation pipeline stage to retrieve the information provided by these methods instead. You can run the aggregation as shown in the following code example:- Cursor cursor = collection.aggregate(Arrays.asList( - new BasicDBObject("$collStats", - new BasicDBObject("storageStats", new BasicDBObject()))), - AggregationOptions.builder().build() - ); - To determine whether a collection is a capped collection, access the value of the - storageStats.cappedfield returned by- Cursorinstance in the preceding example aggregation.- To learn more about the - $collStatsaggregation operator, see the $collStats (aggregation) Server manual entry.
- The following network address-related methods are deprecated and will be removed in v5.0: - The ServerAddress methods - getSocketAddress()and- getSocketAddresses().- Instead of - getSocketAddress(), use the- getByName()instance method of- java.net.InetAddress.- Instead of - getSocketAddresses(), use the- getAllByName()instance method of- java.net.InetAddress.
- The UnixServerAddress method - getUnixSocketAddress().- Instead of - getUnixSocketAddress(), construct an instance of- jnr.unixsocket.UnixSocketAddress. Pass the full path of the UNIX socket file to the constructor. By default, MongoDB creates a UNIX socket file located at- "/tmp/mongodb-27017.sock". To learn more about the- UnixSocketAddress, see the UnixSocketAddress API documentation.
 
- The following methods and types related to the StreamFactory interface are deprecated and scheduled for removal in v5.0: - streamFactoryFactory()method from- MongoClientSettings.Builder
- getStreamFactoryFactory()method from- MongoClientSettings
- NettyStreamFactoryFactoryclass
- NettyStreamFactoryclass
- AsynchronousSocketChannelStreamFactoryclass
- AsynchronousSocketChannelStreamFactoryFactoryclass
- BufferProviderclass
- SocketStreamFactoryclass
- Streamclass
- StreamFactoryclass
- StreamFactoryFactoryclass
- TlsChannelStreamFactoryFactoryclass
 - If you configure Netty by using - MongoClientSettings.Builder.streamFactoryFactory(), your code might resemble the following:- import com.mongodb.connection.netty.NettyStreamFactoryFactory; - // ... - MongoClientSettings settings = MongoClientSettings.builder() - .streamFactoryFactory(NettyStreamFactoryFactory.builder().build()) - .build(); - Replace this code with the TransportSettings.nettyBuilder() as shown in the following example: - import com.mongodb.connection.TransportSettings; - // ... - MongoClientSettings settings = MongoClientSettings.builder() - .transportSettings(TransportSettings.nettyBuilder().build()) - .build(); 
New Features in 4.11
New features of the 4.11 driver release include:
- Support for connecting to MongoDB by using a SOCKS5 proxy. To learn more see Connect to MongoDB by Using a SOCKS5 Proxy. 
Note
The v4.11.3 patch release fixed an issue related to how domain names are validated when you use SOCKS5 proxy functionality, allowing you to use domain names with more than six characters in the top-level domain.
- Added the - getSplitEvent()method to the- ChangeStreamDocumentclass to identify fragments of a change stream event that exceeds 16MB. You must use the aggregation stage- $changeStreamSplitLargeEventin your change stream to handle events that exceed 16MB. To learn more, see Split Large Change Stream Events.
- Added an aggregation stage builder for - $vectorSearch. To learn more, see MongoDB Vector Search.
- Added MongoDB Search index management helpers. To learn more, see MongoDB Search Indexes. 
- Updated Snappy and Zstd compression library dependency versions. To learn more about the current dependency versions, see Compress Network Traffic. 
- Added - getElapsedTime()methods to the following classes to monitor the duration of connection pool events:
- Support for Java 21 virtual threads and structured concurrency. The driver internals were updated to avoid unnecessary pinning of virtual threads and to preserve interrupted status of a thread, as the latter matters for structured concurrency where it is used for cancellation. - To learn more about virtual threads, see the Virtual Threads JDK enhancement proposal. To learn more about structured concurrency, see the Structured Concurrency JDK enhancement proposal. 
- Updated API documentation for the following types: 
What's New in 4.10
New features of the 4.10 driver release include:
- Implementation of the - Accumulators.percentile()and- Accumulators.median()methods for statistical aggregations.
- Interfaces in the - com.mongodb.client.model.searchpackage are now marked as- @Sealedinstead of- @Evolving. Sealed interfaces must not be extended or implemented by consumers of the library.
- Resolved an issue where the driver emitted duplicate log messages for retry operations. The driver now correctly emits one log message for each retry operation. 
- The - org.bson.codecs.Parameterizableinterface is deprecated. Instead of implementing this interface on a custom- Codectype, override the- CodecProvider.get()method on the codec's- CodecProviderif the codec is intended for a parameterized type.
- Support for custom DNS resolvers. 
- Support for Queryable Encryption (QE). To learn more about the requirements for using the QE feature, see the Queryable Encryption Driver Compatibility Table.