Steps: If the deserialization is performed multiple times (single object encoded -> generic record, generic record -> T), the logical type conversion is applied once on the Avro basic type and then tried to be applied on the already converted target type. By doing so, it fails with exception: kotlinx.serialization.SerializationException: Unsupported type for String [is class <your logical type class>].
To make it visible here is an addition to the JUnit test: BankAccountCreatedDataTest:
@Test
fun `serialize data class with uuid customerId and money to record and single object encoded and back`() {
val amount = Money.of(10, "EUR")
val accountId = UUID.randomUUID()
val customerId = CustomerId.random()
val event = BankAccountCreatedData(accountId, customerId, amount)
val resolver = avroSchemaResolver(KotlinExample.avro.schema(BankAccountCreatedData::class))
val record = KotlinExample.avro.toRecord(event)
assertThat(KotlinExample.avro.fromRecord(record, BankAccountCreatedData::class)).isEqualTo(event)
// go down and run through SOE
val singleObjectEncodedBytes = GenericRecordCodec.encodeSingleObject(record)
val recordDecodedFromBytes = GenericRecordCodec.decodeSingleObject(singleObjectEncodedBytes, resolver.invoke())
val deserializedEvent = AvroKotlinSerialization().fromRecord<BankAccountCreatedData>(recordDecodedFromBytes)
assertThat(deserializedEvent).isEqualTo(event)
}
Expected behaviour
Attempt to convert already converted logical type just returns it.
Steps to reproduce
kotlinx.serialization.SerializationException: Unsupported type for String [is class <your logical type class>]
.BankAccountCreatedDataTest
:Expected behaviour
Attempt to convert already converted logical type just returns it.
Actual behaviour
Exception...