Docs Menu
Docs Home
/ / /
Java Sync Driver

What's New

On this page

  • What's New in 5.2.1
  • What's New in 5.2
  • What's New in 5.1.3
  • What's New in 5.1.2
  • What's New in 5.1.1
  • What's New in 5.1
  • What's New in 5.0
  • What's New in 4.11
  • What's New in 4.10

Learn what's new in:

  • Version 5.2.1

  • Version 5.2

  • Version 5.1.3

  • Version 5.1.2

  • Version 5.1.1

  • Version 5.1

  • Version 5.0

  • Version 4.11

  • Version 4.10

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.UnsatisfiedLinkError when initializing libmongocrypt bindings.

  • Fixes a bug that caused the mongodb-driver-core package to error when deployed to an OSGi runtime. The `` Import-Package org.mongodb:mongodb-driver-core`` manifest attribute no longer requires the com.oracle.svm.core.annotate.* packages.

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";

The 5.1.3 driver patch release includes the following changes:

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 MongoCollection instance.

  • 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.

The 5.1.1 driver patch release includes the following changes:

  • When using the MONGODB-OIDC authentication mechanism, you must not include comma characters in the authMechanismProperties connection string value. To learn more about this behavior, see the MONGODB-OIDC section of the Enterprise Authentication guide.

  • Optimizes GridFS throughput by removing redundant byte array cloning. The GridFSDownloadStream and GridFSUploadStream types use the BsonDocument type instead of Document.

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:

  • 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.

  • 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 MONGODB-OIDC section of the Enterprise Authentication Mechanisms guide.

  • Introduces the serverMonitoringMode connection URI option. For more information about this option, see the Connection Options guide.

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:

  • 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.

  • The getElapsedTime() method on com.mongodb.event.ConnectionReadyEvent includes 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.ConnectionCheckedOutFailedEvent and com.mongodb.event.ConnectionCheckedOutEvent include 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.

The 5.0 driver release introduces the following features:

  • Adds support for the authorizedCollection option of the listCollections command. 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 authorizedCollections option. 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 authorizedCollections option, 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.

This section includes the following information:

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 DBCollection class are deprecated. The corresponding server commands are deprecated in MongoDB v6.2 and later. Use the $collStats aggregation 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.capped field returned by Cursor instance in the preceding example aggregation.

    To learn more about the $collStats aggregation operator, see the $collStats (aggregation) Server manual entry.

  • The following network address-related methods are deprecated and will be removed in v5.0:

  • 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

    • NettyStreamFactoryFactory class

    • NettyStreamFactory class

    • AsynchronousSocketChannelStreamFactory class

    • AsynchronousSocketChannelStreamFactoryFactory class

    • BufferProvider class

    • SocketStreamFactory class

    • Stream class

    • StreamFactory class

    • StreamFactoryFactory class

    • TlsChannelStreamFactoryFactory class

    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 of the 4.11 driver release include:

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 ChangeStreamDocument class to identify fragments of a change stream event that exceeds 16MB. You must use the aggregation stage $changeStreamSplitLargeEvent in 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 Atlas Vector Search.

  • Added Atlas Search index management helpers. To learn more, see Atlas Search Indexes.

  • Updated Snappy and Zstd compression library dependency versions. To learn more about the current dependency versions, see Network Compression.

  • 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:

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.search package are now marked as @Sealed instead 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.Parameterizable interface is deprecated. Instead of implementing this interface on a custom Codec type, override the CodecProvider.get() method on the codec's CodecProvider if 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.

Back

Quick Reference