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

Serializing POJO with CharSequence fails with 4.10.0 driver

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.10.1
    • Affects Version/s: 4.10.0
    • Component/s: Codecs, POJO
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      Inserting POJO that has CharSequence field fails as of 4.10.0 library version. The error I am seeing is this:

      kotlinx.serialization.SerializationException: Class 'String' is not registered for polymorphic serialization in the scope of 'CharSequence'.
      To be registered automatically, class 'String' has to be '@Serializable', and the base class 'CharSequence' has to be sealed and '@Serializable'.
      Alternatively, register the serializer for 'String' explicitly in a corresponding SerializersModule. 

      How to Reproduce

      Please look at the attached example: mongo-example.zip. Just run Main class and the error will occur.

      Additional Background

      As soon as I change dependency to 4.9.1 the error goes away. Also if I exclude org.mongodb:bson-kotlinx from gradle dependency. So, we should have a way to not have Kotlin serializer as this is just java project and Kotlin serializer is throwing this error which we cannot fix.

            Assignee:
            ross@mongodb.com Ross Lawley
            Reporter:
            radicr@gmail.com Radovan Radic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: