CORDA-2871: Sanity fixes! (#63)

* Improve message for SandboxClassLoadingException.
* Fix serialisation API for using sandboxed environment.
This commit is contained in:
Chris Rankin 2019-09-09 18:14:33 +01:00 committed by GitHub
parent f68c4b3308
commit 7a6c18156c

View File

@ -75,11 +75,17 @@ inline fun <reified T : Any> SerializedBytes<T>.deserializeFor(classLoader: Sand
}
fun ByteSequence.deserializeTo(clazz: Class<*>, classLoader: SandboxClassLoader): Any {
return deserializeTo(clazz, classLoader, SerializationFactory.defaultFactory)
val factory = SerializationFactory.defaultFactory
return deserializeTo(clazz, classLoader, factory, factory.defaultContext)
}
fun ByteSequence.deserializeTo(clazz: Class<*>, classLoader: SandboxClassLoader, factory: SerializationFactory): Any {
val obj = factory.deserialize(this, Any::class.java, factory.defaultContext)
fun ByteSequence.deserializeTo(
clazz: Class<*>,
classLoader: SandboxClassLoader,
factory: SerializationFactory,
context: SerializationContext
): Any {
val obj = factory.deserialize(this, Any::class.java, context)
return if (clazz.isInstance(obj)) {
obj
} else {