ENT-2608 - Fix deserialization of evolution (#4096)

Fix deserialization could mix together the object trees of two threads when passing through evolution (ENT-2608).
This commit is contained in:
szymonsztuka 2018-10-19 20:30:08 +01:00 committed by GitHub
parent 72cab90577
commit 3a8fd51a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,7 +116,6 @@ abstract class EvolutionSerializer(
factory: SerializerFactory,
constructor: KFunction<Any>,
readersAsSerialized: Map<String, OldParam>): AMQPSerializer<Any> {
val constructorArgs = arrayOfNulls<Any?>(constructor.parameters.size)
// Java doesn't care about nullability unless it's a primitive in which
// case it can't be referenced. Unfortunately whilst Kotlin does apply
@ -144,7 +143,7 @@ abstract class EvolutionSerializer(
}
}
}
return EvolutionSerializerViaConstructor(new.type, factory, readersAsSerialized, constructor, constructorArgs)
return EvolutionSerializerViaConstructor(new.type, factory, readersAsSerialized, constructor)
}
private fun makeWithSetters(
@ -210,8 +209,7 @@ class EvolutionSerializerViaConstructor(
clazz: Type,
factory: SerializerFactory,
oldReaders: Map<String, EvolutionSerializer.OldParam>,
kotlinConstructor: KFunction<Any>,
private val constructorArgs: Array<Any?>) : EvolutionSerializer(clazz, factory, oldReaders, kotlinConstructor) {
kotlinConstructor: KFunction<Any>) : EvolutionSerializer(clazz, factory, oldReaders, kotlinConstructor) {
/**
* Unlike a normal [readObject] call where we simply apply the parameter deserialisers
* to the object list of values we need to map that list, which is ordered per the
@ -226,6 +224,7 @@ class EvolutionSerializerViaConstructor(
): Any {
if (obj !is List<*>) throw NotSerializableException("Body of described type is unexpected $obj")
val constructorArgs : Array<Any?> = arrayOfNulls<Any?>(kotlinConstructor.parameters.size)
// *must* read all the parameters in the order they were serialized
oldReaders.values.zip(obj).map { it.first.readProperty(it.second, schemas, input, constructorArgs, context) }