Docs Menu

Docs HomeDevelop ApplicationsMongoDB DriversKotlin Coroutine

What's New

On this page

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

  • Version 5.0

  • Version 4.11

  • Version 4.10

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.

  • Fixes an issue in which operations used the incorrect codec when using a polymorphic MongoCollection instance. This ensures that discriminator information is not lost when using bson-kotlinx.

  • Fixes an issue in which the class discriminator was the first field when decoding, resulting in field type errors when using a polymorphic MongoCollection instance.

  • Support for polymorphic serialization.

  • Introduces the serverMonitoringMode connection URI option.

New features of the 5.0 driver release include:

  • The KotlinSerializerCodecProvider constructor now accepts serializersModule and bsonConfiguration objects:

    KotlinSerializerCodec.create(clazz.kotlin, serializersModule=serializersModule, bsonConfiguration=bsonConfiguration)

    This makes it easier to customize your configuration.

  • Fixes a Kotlin reflection bug that resulted in container type erasure.

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

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

  • Support for connecting to MongoDB by using a SOCKS5 proxy.

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

  • Added an aggregation stage builder for $vectorSearch.

  • Added Atlas Search index management helpers.

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

Important

Starting in version 4.10.1 of the Kotlin driver, you must add the bson-kotlinx library as an explicit dependency to use the kotlinx-serialization library.

  • Support for Kotlin server-side usage, both for coroutines and for synchronous applications.

  • Codec support for Kotlin data classes.

  • Support for the kotlinx.serialization library

← Quick Reference