Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5641

Runtime error when creating a MongoClient with old version of kotlinx-datetime in classpath

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 5.2.1
    • Affects Version/s: 5.2.0
    • Component/s: Kotlin
    • None
    • Java Drivers
    • Not Needed

      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.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            mccreight@mediamarktsaturn.com Mervyn McCreight
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: