Hi all, I have the following issue and I would be ...
# serialization
i
Hi all, I have the following issue and I would be grateful if someone could point me in the right direction. I am using kotlinx.serialization in KMongo (org.litote.kmongokmongo coroutine serialization3.12.2) I have the following data class which is in a file I cannot edit:
Copy code
data class User(
    val username: String,
    val email: String,
    val firstName: String,
    val lastName: String,
    val password: String,
    val role: Role,
    val createdAt: LocalDateTime,
    val updatedAt: LocalDateTime
)
So, in my file I create a serializer for it like this:
Copy code
@Serializer(forClass = User::class)
object UserSerializer {}
Now, everything seems to work OK when deserializing the data, however when KMongo tries to serialize it and send it to DB, I get a nasty java exception stack with the following message:
Copy code
java.lang.IndexOutOfBoundsException: com.example.domain.users.User descriptor has only 8 elements, index: 0
After going through code, I found that in file PluginGeneratedSerialDescriptor.kt there is an overriden fun getElementDescriptor in which property generatedSerializer is trying to get accessed, but it is null and this causes the exception. Does anyone know if this is a bug, or I'm doing something wrong here?
d
That looks weird. Can you specify which versions you're using?