mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
ENT-6750: Checkpoint serialisation to support primitive void.class (#7448)
This commit is contained in:
parent
a6786769e5
commit
825a970b92
@ -432,7 +432,7 @@ object LoggerSerializer : Serializer<Logger>() {
|
||||
object ClassSerializer : Serializer<Class<*>>() {
|
||||
override fun read(kryo: Kryo, input: Input, type: Class<Class<*>>): Class<*> {
|
||||
val className = input.readString()
|
||||
return Class.forName(className, true, kryo.classLoader)
|
||||
return if (className == "void") Void.TYPE else Class.forName(className, true, kryo.classLoader)
|
||||
}
|
||||
|
||||
override fun write(kryo: Kryo, output: Output, clazz: Class<*>) {
|
||||
|
@ -351,6 +351,20 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
||||
assertEquals(randomHash, exception2.requested)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `serialize - deserialize primative void`() {
|
||||
val original = JavaVoidHolder()
|
||||
val roundtrip = original.checkpointSerialize(context).checkpointDeserialize(context)
|
||||
assertThat(roundtrip.voidClass).isEqualTo(original.voidClass)
|
||||
}
|
||||
|
||||
class JavaVoidHolder {
|
||||
val voidClass: Class<Void> = Void.TYPE
|
||||
init {
|
||||
check(voidClass.name == "void") // Sanity check to make sure we're dealing with the primitive void
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `compression has the desired effect`() {
|
||||
compression ?: return
|
||||
@ -373,6 +387,7 @@ class KryoTests(private val compression: CordaSerializationEncoding?) {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `compression reduces number of bytes significantly`() {
|
||||
@Suppress("unused")
|
||||
class Holder(val holder: ByteArray)
|
||||
|
||||
val obj = Holder(ByteArray(20000))
|
||||
|
Loading…
Reference in New Issue
Block a user