Summary
When the project has an old version of kotlinx-datetime (I could reproduce it with "0.3.1", but haven't tried further) an exception during runtime occurs when one tries to create a MongoClient. If you have the most recent version in the class path everything works fine.
The problem is that one does not necessarily have control over possible third party dependencies internally depending on older versions of kotlinx-datetime.
The example stated in the README of the reproducer refers to a library most possibly only used for testing purposes. This means that even if the production-code of the affected project does not use kotlinx-datetime itself and therefore has no need to actually be able to serialize/deserialize kotlinx-datetime-types into BSON, the error would still occur.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
Driver Version: Kotlin 5.2.0
MongoDB Server Version is not relevant, it's a client side error when creating a MongoClient.
How to Reproduce
Please see https://github.com/mervyn-mccreight/bson-kotlinx-5.2.0-datetime-bug-reproducer for a small reproducing project. I tried to summarise the possible reasons and a solution suggestion in the README of the reproducer.
Additional Background
I think the behaviour was introduced with the integration of the kotlinx.datetime support (JAVA-5330). Please see the README in the reproducer repository, I tried to document my findings there.
- is related to
-
JAVA-5330 Add Kotlinx datetime serializers
- Closed