-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
-
Summary
Given a data class Foo that has a property of type `kotlinx.datetime.LocalTime`, and another data class Bar that has a property of type `List<Foo>`
No codec is found for the `LocalTime` despite a custom codec being provided and working when no lists are involved.
Doesn't work
data class Foo( val time: LocalTime ) data class Bar( val foos: List<Foo> )
Works fine
*data class Foo( val time: LocalTime ) data class Bar( val foo: Foo )*
driver version 4.11.0
How to Reproduce
Use the above data classes and try to insert the `Bar` class to a collection with custom codec:
class LocalTimeCodec: Codec<LocalTime> { override fun encode(writer: BsonWriter, value: LocalTime, encoderContext: EncoderContext) { writer.writeString(value.toString()) } override fun getEncoderClass(): Class<LocalTime> = LocalTime::class.java override fun decode(reader: BsonReader, decoderContext: DecoderContext): LocalTime = LocalTime.parse(reader.readString()) }