ENT-11264 Fixed initialization of field serializer

This commit is contained in:
Arshad Mahmood 2023-12-12 16:27:30 +00:00
parent b375c7da21
commit 91d4c33513
7 changed files with 11 additions and 14 deletions

View File

@ -8272,8 +8272,6 @@ public static final class net.corda.core.utilities.ProgressTracker$STARTING exte
@NotNull
public static final net.corda.core.utilities.ProgressTracker$STARTING INSTANCE
##
public static interface net.corda.core.utilities.ProgressTracker$SerializableAction extends java.io.Serializable, rx.functions.Action1
##
@CordaSerializable
public static class net.corda.core.utilities.ProgressTracker$Step extends java.lang.Object
public <init>(String)
@ -8297,8 +8295,6 @@ public static final class net.corda.core.utilities.ProgressTracker$UNSTARTED ext
public interface net.corda.core.utilities.PropertyDelegate
public abstract T getValue(Object, kotlin.reflect.KProperty)
##
public interface net.corda.core.utilities.SerializableLambda2 extends java.io.Serializable, kotlin.jvm.functions.Function2
##
public final class net.corda.core.utilities.SgxSupport extends java.lang.Object
public static final boolean isInsideEnclave()
@NotNull

View File

@ -6,7 +6,6 @@ import net.corda.core.flows.StartableByRPC
import net.corda.core.identity.Party
import net.corda.core.internal.concurrent.transpose
import net.corda.core.messaging.startFlow
import net.corda.core.utilities.SerializableLambda2
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.minutes
import net.corda.node.services.statemachine.StateTransitionException
@ -16,6 +15,7 @@ import net.corda.testing.core.singleIdentity
import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver
import org.junit.Test
import java.io.Serializable
import java.sql.SQLTransientConnectionException
import java.util.concurrent.CompletableFuture
import kotlin.test.assertFailsWith
@ -23,6 +23,8 @@ import kotlin.test.assertTrue
class FlowExternalAsyncOperationTest : AbstractFlowExternalOperationTest() {
private fun interface SerializableLambda2<S, T, R> : (S, T) -> R, Serializable
@Test(timeout = 300_000)
fun `external async operation`() {
driver(DriverParameters(notarySpecs = emptyList(), startNodesInProcess = true)) {

View File

@ -10,7 +10,6 @@ import net.corda.core.internal.packageName
import net.corda.core.messaging.startFlow
import net.corda.core.node.services.queryBy
import net.corda.core.transactions.TransactionBuilder
import net.corda.core.utilities.SerializableLambda2
import net.corda.core.utilities.getOrThrow
import net.corda.core.utilities.minutes
import net.corda.testing.contracts.DummyContract
@ -22,12 +21,15 @@ import net.corda.testing.driver.DriverParameters
import net.corda.testing.driver.driver
import net.corda.testing.node.internal.cordappsForPackages
import org.junit.Test
import java.io.Serializable
import java.sql.SQLTransientConnectionException
import kotlin.test.assertFailsWith
import kotlin.test.assertTrue
class FlowExternalOperationTest : AbstractFlowExternalOperationTest() {
private fun interface SerializableLambda2<S, T, R> : (S, T) -> R, Serializable
@Test(timeout = 300_000)
fun `external operation`() {
driver(DriverParameters(notarySpecs = emptyList(), startNodesInProcess = true)) {

View File

@ -11,7 +11,6 @@ import net.corda.nodeapi.internal.serialization.kryo.KRYO_CHECKPOINT_CONTEXT
import net.corda.serialization.internal.CheckpointSerializationContextImpl
import net.corda.testing.core.SerializationEnvironmentRule
import org.assertj.core.api.Assertions.assertThat
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
@ -62,7 +61,6 @@ class KotlinUtilsTest {
}
@Test(timeout=300_000)
@Ignore("TODO JDK17:Fixme serializable lambda issue")
fun `checkpointing a transient property with capturing lambda`() {
val original = CapturingTransientProperty("Hello")
val originalVal = original.transientVal

View File

@ -5,7 +5,6 @@ import net.corda.core.internal.uncheckedCast
import net.corda.core.serialization.CordaSerializable
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.Serializable
import java.time.Duration
import java.util.concurrent.ExecutionException
import java.util.concurrent.Future
@ -134,6 +133,3 @@ fun <V> Future<V>.getOrThrow(timeout: Duration? = null): V = try {
} catch (e: ExecutionException) {
throw e.cause!!
}
/** Functional interfaces for Serializeable Lambdas */
fun interface SerializableLambda2<S, T, R> : (S, T) -> R, Serializable

View File

@ -39,7 +39,7 @@ class ProgressTracker(vararg inputSteps: Step) {
private val log = contextLogger()
}
internal fun interface SerializableAction<T>: Action1<T>, Serializable
private fun interface SerializableAction<T>: Action1<T>, Serializable
@CordaSerializable
sealed class Change(val progressTracker: ProgressTracker) {

View File

@ -93,7 +93,10 @@ class CordaClassResolver(serializationContext: CheckpointSerializationContext) :
val serializer = when {
objectInstance != null -> KotlinObjectSerializer(objectInstance)
kotlin.jvm.internal.Lambda::class.java.isAssignableFrom(targetType) -> // Kotlin lambdas extend this class and any captured variables are stored in synthetic fields
FieldSerializer<Any>(kryo, targetType).apply { fieldSerializerConfig.ignoreSyntheticFields = false }
FieldSerializer<Any>(kryo, targetType).apply {
fieldSerializerConfig.ignoreSyntheticFields = false
updateFields()
}
Throwable::class.java.isAssignableFrom(targetType) -> ThrowableSerializer(kryo, targetType)
else -> maybeWrapForInterning(kryo.getDefaultSerializer(targetType), targetType)
}