diff --git a/core/src/main/kotlin/net/corda/core/serialization/amqp/DeserializationInput.kt b/core/src/main/kotlin/net/corda/core/serialization/amqp/DeserializationInput.kt index bcb168e22d..2859dbb989 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/amqp/DeserializationInput.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/amqp/DeserializationInput.kt @@ -11,8 +11,7 @@ import java.lang.reflect.Type import java.nio.ByteBuffer import java.util.* - -data class classAndEnvelope(val obj: T, val envelope: Envelope) +data class objectAndEnvelope(val obj: T, val envelope: Envelope) /** * Main entry point for deserializing an AMQP encoded object. @@ -65,12 +64,12 @@ class DeserializationInput(internal val serializerFactory: SerializerFactory = S @Throws(NotSerializableException::class) - inline fun deserializeAndReturnEnvelope(bytes: SerializedBytes): classAndEnvelope = + inline internal fun deserializeAndReturnEnvelope(bytes: SerializedBytes): objectAndEnvelope = deserializeAndReturnEnvelope(bytes, T::class.java) @Throws(NotSerializableException::class) - fun getEnvelope(bytes: SerializedBytes): Envelope { + private fun getEnvelope(bytes: SerializedBytes): Envelope { // Check that the lead bytes match expected header if (!subArraysEqual(bytes.bytes, 0, 8, AmqpHeaderV1_0.bytes, 0)) { throw NotSerializableException("Serialization header does not match.") @@ -87,7 +86,7 @@ class DeserializationInput(internal val serializerFactory: SerializerFactory = S @Throws(NotSerializableException::class) - fun des(bytes: SerializedBytes, clazz: Class, generator: (SerializedBytes, Class) -> R): R { + private fun des(bytes: SerializedBytes, clazz: Class, generator: (SerializedBytes, Class) -> R): R { try { return generator(bytes, clazz) } catch(nse: NotSerializableException) { @@ -113,11 +112,11 @@ class DeserializationInput(internal val serializerFactory: SerializerFactory = S } @Throws(NotSerializableException::class) - fun deserializeAndReturnEnvelope(bytes: SerializedBytes, clazz: Class): classAndEnvelope { - return des>(bytes, clazz) { bytes, clazz -> + internal fun deserializeAndReturnEnvelope(bytes: SerializedBytes, clazz: Class): objectAndEnvelope { + return des>(bytes, clazz) { bytes, clazz -> val envelope = getEnvelope(bytes) // Now pick out the obj and schema from the envelope. - classAndEnvelope(clazz.cast(readObjectOrNull(envelope.obj, envelope.schema, clazz)), envelope) + objectAndEnvelope(clazz.cast(readObjectOrNull(envelope.obj, envelope.schema, clazz)), envelope) } }