Skip to content

Commit

Permalink
ENT-11264 Fixed initialization of field serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
arshadm committed Dec 13, 2023
1 parent b375c7d commit 91d4c33
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .ci/api-current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,13 +15,16 @@ 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
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 91d4c33

Please sign in to comment.