mirror of
https://github.com/corda/corda.git
synced 2024-12-24 15:16:45 +00:00
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:
parent
72cab90577
commit
3a8fd51a08
@ -116,7 +116,6 @@ abstract class EvolutionSerializer(
|
|||||||
factory: SerializerFactory,
|
factory: SerializerFactory,
|
||||||
constructor: KFunction<Any>,
|
constructor: KFunction<Any>,
|
||||||
readersAsSerialized: Map<String, OldParam>): AMQPSerializer<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
|
// Java doesn't care about nullability unless it's a primitive in which
|
||||||
// case it can't be referenced. Unfortunately whilst Kotlin does apply
|
// 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(
|
private fun makeWithSetters(
|
||||||
@ -210,8 +209,7 @@ class EvolutionSerializerViaConstructor(
|
|||||||
clazz: Type,
|
clazz: Type,
|
||||||
factory: SerializerFactory,
|
factory: SerializerFactory,
|
||||||
oldReaders: Map<String, EvolutionSerializer.OldParam>,
|
oldReaders: Map<String, EvolutionSerializer.OldParam>,
|
||||||
kotlinConstructor: KFunction<Any>,
|
kotlinConstructor: KFunction<Any>) : EvolutionSerializer(clazz, factory, oldReaders, kotlinConstructor) {
|
||||||
private val constructorArgs: Array<Any?>) : EvolutionSerializer(clazz, factory, oldReaders, kotlinConstructor) {
|
|
||||||
/**
|
/**
|
||||||
* Unlike a normal [readObject] call where we simply apply the parameter deserialisers
|
* 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
|
* to the object list of values we need to map that list, which is ordered per the
|
||||||
@ -226,6 +224,7 @@ class EvolutionSerializerViaConstructor(
|
|||||||
): Any {
|
): Any {
|
||||||
if (obj !is List<*>) throw NotSerializableException("Body of described type is unexpected $obj")
|
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
|
// *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) }
|
oldReaders.values.zip(obj).map { it.first.readProperty(it.second, schemas, input, constructorArgs, context) }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user