mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Investigating DuplicateSerializerLogTest
This commit is contained in:
parent
0123b141d3
commit
d811f6f456
@ -311,6 +311,7 @@ allprojects {
|
||||
}
|
||||
|
||||
tasks.withType(Test).configureEach {
|
||||
jvmArgs += project(":node:capsule").file("src/main/resources/node-jvm-args.txt").readLines()
|
||||
jvmArgs += "--add-modules=jdk.incubator.foreign" // For the SharedMemoryIncremental
|
||||
forkEvery = 20
|
||||
ignoreFailures = project.hasProperty('tests.ignoreFailures') ? project.property('tests.ignoreFailures').toBoolean() : false
|
||||
|
@ -6,6 +6,7 @@ import co.paralleluniverse.io.serialization.kryo.ExternalizableKryoSerializer
|
||||
import co.paralleluniverse.io.serialization.kryo.JdkProxySerializer
|
||||
import co.paralleluniverse.io.serialization.kryo.KryoSerializer
|
||||
import co.paralleluniverse.io.serialization.kryo.ReferenceSerializer
|
||||
import com.esotericsoftware.kryo.ClassResolver
|
||||
import com.esotericsoftware.kryo.Kryo
|
||||
import com.esotericsoftware.kryo.KryoException
|
||||
import com.esotericsoftware.kryo.Serializer
|
||||
@ -24,6 +25,7 @@ import net.corda.core.serialization.SerializedBytes
|
||||
import net.corda.core.serialization.internal.CheckpointSerializationContext
|
||||
import net.corda.core.serialization.internal.CheckpointSerializer
|
||||
import net.corda.core.utilities.ByteSequence
|
||||
import net.corda.core.utilities.contextLogger
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.serialization.internal.AlwaysAcceptEncodingWhitelist
|
||||
import net.corda.serialization.internal.ByteBufferInputStream
|
||||
@ -103,7 +105,7 @@ object KryoCheckpointSerializer : CheckpointSerializer {
|
||||
fun createFiberSerializer(context: CheckpointSerializationContext): KryoSerializer {
|
||||
// val serializer = Fiber.getFiberSerializer(classResolver, false) as KryoSerializer
|
||||
// (this as ReplaceableObjectKryo).isIgnoreInaccessibleClasses = true
|
||||
val kryo = Kryo(CordaClassResolver(context), MapReferenceResolver())
|
||||
val kryo = LoggingKryo(CordaClassResolver(context), MapReferenceResolver())
|
||||
kryo.isRegistrationRequired = false
|
||||
// Needed because of https://github.com/EsotericSoftware/kryo/issues/864
|
||||
kryo.setOptimizedGenerics(false)
|
||||
@ -111,6 +113,40 @@ object KryoCheckpointSerializer : CheckpointSerializer {
|
||||
return Fiber.getFiberSerializer(kryo, false) as KryoSerializer
|
||||
}
|
||||
|
||||
private class LoggingKryo(classResolver: ClassResolver, referenceResolver: MapReferenceResolver) : Kryo(classResolver, referenceResolver) {
|
||||
private companion object {
|
||||
private val log = contextLogger()
|
||||
}
|
||||
override fun writeObject(output: Output?, `object`: Any?, serializer: Serializer<*>?) {
|
||||
log.info("writeObject ${`object`} serializer = $serializer")
|
||||
super.writeObject(output, `object`, serializer)
|
||||
}
|
||||
|
||||
override fun writeClassAndObject(output: Output?, `object`: Any?) {
|
||||
log.info("writeClassAndObject ${`object`}")
|
||||
|
||||
super.writeClassAndObject(output, `object`)
|
||||
}
|
||||
|
||||
override fun writeObject(output: Output?, `object`: Any?) {
|
||||
log.info("writeObject ${`object`}")
|
||||
|
||||
super.writeObject(output, `object`)
|
||||
}
|
||||
|
||||
override fun writeObjectOrNull(output: Output?, `object`: Any?, serializer: Serializer<*>?) {
|
||||
log.info("writeObjectOrNull ${`object`} serializer = $serializer")
|
||||
|
||||
super.writeObjectOrNull(output, `object`, serializer)
|
||||
}
|
||||
|
||||
override fun writeObjectOrNull(output: Output?, `object`: Any?, type: Class<*>?) {
|
||||
log.info("writeObjectOrNull ${`object`}")
|
||||
|
||||
super.writeObjectOrNull(output, `object`, type)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy of [co.paralleluniverse.io.serialization.kryo.KryoUtil.registerCommonClasses] ...
|
||||
*/
|
||||
|
@ -1,3 +1,9 @@
|
||||
--add-opens=java.base/java.lang=ALL-UNNAMED
|
||||
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
|
||||
--add-opens=java.base/java.nio=ALL-UNNAMED
|
||||
--add-opens=java.base/java.security=ALL-UNNAMED
|
||||
--add-opens=java.base/java.security.cert=ALL-UNNAMED
|
||||
--add-opens=java.base/java.time=ALL-UNNAMED
|
||||
--add-opens=java.base/java.util=ALL-UNNAMED
|
||||
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
|
||||
--add-opens=java.sql/java.sql=ALL-UNNAMED
|
||||
|
@ -8,7 +8,7 @@ class DifficultToSerialize {
|
||||
// This map breaks the rules for the put method. Making the normal map serializer fail.
|
||||
|
||||
open class BrokenMapBaseImpl<K,V>(delegate: MutableMap<K, V> = mutableMapOf()) : MutableMap<K,V> by delegate {
|
||||
override fun put(key: K, value: V): V? = throw FlowException("Broken on purpose")
|
||||
override fun put(key: K, value: V): V? = throw FlowException("Broken on purpose BrokenMapBaseImpl")
|
||||
}
|
||||
|
||||
// A class to test custom serializers applied to implementations
|
||||
|
@ -8,6 +8,8 @@ import net.corda.core.serialization.CheckpointCustomSerializer
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.driver.logFile
|
||||
import net.corda.testing.node.internal.cordappsForPackages
|
||||
import net.corda.testing.node.internal.internalDriver
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.junit.Test
|
||||
import java.time.Duration
|
||||
@ -15,7 +17,7 @@ import java.time.Duration
|
||||
class DuplicateSerializerLogTest{
|
||||
@Test(timeout=300_000)
|
||||
fun `check duplicate serialisers are logged`() {
|
||||
driver {
|
||||
internalDriver(cordappsForAllNodes = cordappsForPackages(javaClass.packageName)) {
|
||||
val node = startNode(startInSameProcess = false).getOrThrow()
|
||||
node.rpc.startFlow(::TestFlow).returnValue.get()
|
||||
|
||||
|
@ -191,11 +191,11 @@ class TestCorDapp {
|
||||
class BrokenPublicKeySerializer :
|
||||
CheckpointCustomSerializer<PublicKey, String> {
|
||||
override fun toProxy(obj: PublicKey): String {
|
||||
throw FlowException("Broken on purpose")
|
||||
throw FlowException("Broken on purpose BrokenPublicKeySerializer.toProxy")
|
||||
}
|
||||
|
||||
override fun fromProxy(proxy: String): PublicKey {
|
||||
throw FlowException("Broken on purpose")
|
||||
throw FlowException("Broken on purpose BrokenPublicKeySerializer.fromProxy")
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,11 +203,11 @@ class TestCorDapp {
|
||||
class BrokenEdDSAPublicKeySerializer :
|
||||
CheckpointCustomSerializer<EdDSAPublicKey, String> {
|
||||
override fun toProxy(obj: EdDSAPublicKey): String {
|
||||
throw FlowException("Broken on purpose")
|
||||
throw FlowException("Broken on purpose BrokenEdDSAPublicKeySerializer.toProxy")
|
||||
}
|
||||
|
||||
override fun fromProxy(proxy: String): EdDSAPublicKey {
|
||||
throw FlowException("Broken on purpose")
|
||||
throw FlowException("Broken on purpose BrokenEdDSAPublicKeySerializer.fromProxy")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -522,6 +522,6 @@ class FlowReloadAfterCheckpointTest {
|
||||
}
|
||||
|
||||
internal class BrokenMap<K, V>(delegate: MutableMap<K, V> = mutableMapOf()) : MutableMap<K, V> by delegate {
|
||||
override fun put(key: K, value: V): V = throw IllegalStateException("Broken on purpose")
|
||||
override fun put(key: K, value: V): V = throw IllegalStateException("Broken on purpose BrokenMap")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user