Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 75 forks source link

UUIDSerializer: Cast to parent type to deserialize a UUID within a list #427

Closed desilvai-target closed 1 year ago

desilvai-target commented 1 year ago

The UUIDSerializer's deserializer will fail with a ClassCastException when the UUID is embedded in a list (e.g., val foo: Collection<@Contextual UUID> = emptyList()). The decoder in this example is a ListDecoder rather than the expected BsonFlexibleDecoder triggering the exception. Both, however, are FlexibleDecoder objects and the reader field is declared there. Updated the cast to this parent type, resolving the issue. The existing tests pass with this change.

If you need more info, please let me know.

zigzago commented 1 year ago

Thank you !