From e4c1db4db68f81834097ab3c06e453259ea36129 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 27 Nov 2018 13:39:54 +0000 Subject: [PATCH] CORDA-2248 Remove spring boot hack. (#4305) * CORDA-2248 Remove spring boot hack. --- .../internal/amqp/AMQPSerializationScheme.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializationScheme.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializationScheme.kt index 1f530f5434..b9feeccc0a 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializationScheme.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/amqp/AMQPSerializationScheme.kt @@ -189,20 +189,24 @@ abstract class AbstractAMQPSerializationScheme( } override fun deserialize(byteSequence: ByteSequence, clazz: Class, context: SerializationContext): T { - var contextToUse = context - if (context.useCase == SerializationContext.UseCase.RPCClient) { - contextToUse = context.withClassLoader(getContextClassLoader()) - } - val serializerFactory = getSerializerFactory(contextToUse) + // This is a hack introduced in version 3 to fix a spring boot issue - CORDA-1747. + // It breaks the shell because it overwrites the CordappClassloader with the system classloader that doesn't know about any CorDapps. + // In case a spring boot serialization issue with generics is found, a better solution needs to be found to address it. +// var contextToUse = context +// if (context.useCase == SerializationContext.UseCase.RPCClient) { +// contextToUse = context.withClassLoader(getContextClassLoader()) +// } + val serializerFactory = getSerializerFactory(context) return DeserializationInput(serializerFactory).deserialize(byteSequence, clazz, context) } override fun serialize(obj: T, context: SerializationContext): SerializedBytes { - var contextToUse = context - if (context.useCase == SerializationContext.UseCase.RPCClient) { - contextToUse = context.withClassLoader(getContextClassLoader()) - } - val serializerFactory = getSerializerFactory(contextToUse) + // See the above comment. +// var contextToUse = context +// if (context.useCase == SerializationContext.UseCase.RPCClient) { +// contextToUse = context.withClassLoader(getContextClassLoader()) +// } + val serializerFactory = getSerializerFactory(context) return SerializationOutput(serializerFactory).serialize(obj, context) }