ENT-6750: Checkpoint serialisation to support primitive void.class (#7448)

This commit is contained in:
Shams Asari 2023-08-21 09:49:39 +01:00 committed by GitHub
parent a6786769e5
commit 825a970b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -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<*>) {

View File

@ -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))