Merge remote-tracking branch 'open/master' into kat-merge-20180517

This commit is contained in:
Katelyn Baker
2018-05-17 15:04:51 +01:00
80 changed files with 6509 additions and 3351 deletions

View File

@ -10,6 +10,7 @@
package net.corda.core.concurrent
import net.corda.core.serialization.CordaSerializable
import java.util.concurrent.CompletableFuture
import java.util.concurrent.Future
@ -17,6 +18,7 @@ import java.util.concurrent.Future
* Same as [Future] with additional methods to provide some of the features of [java.util.concurrent.CompletableFuture] while minimising the API surface area.
* In Kotlin, to avoid compile errors, whenever CordaFuture is used in a parameter or extension method receiver type, its type parameter should be specified with out variance.
*/
@CordaSerializable
interface CordaFuture<V> : Future<V> {
/**
* Run the given callback when this future is done, on the completion thread.

View File

@ -20,6 +20,7 @@ import rx.Observable
* [FlowHandle] is a serialisable handle for the started flow, parameterised by the type of the flow's return value.
*/
@DoNotImplement
@CordaSerializable
interface FlowHandle<A> : AutoCloseable {
/**
* The started state machine's ID.

View File

@ -124,11 +124,7 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
}
/**
* FungibleStateQueryCriteria: provides query by attributes defined in [VaultSchema.VaultFungibleState]
*
* Valid TokenType implementations defined by Amount<T> are
* [Currency] as used in [Cash] contract state
* [Commodity] as used in [CommodityContract] state
* FungibleStateQueryCriteria: provides query by attributes defined in [VaultSchema.VaultFungibleStates]
*/
data class FungibleAssetQueryCriteria @JvmOverloads constructor(val participants: List<AbstractParty>? = null,
val owner: List<AbstractParty>? = null,
@ -150,8 +146,6 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
*
* Params
* [expression] refers to a (composable) type safe [CriteriaExpression]
*
* Refer to [CommercialPaper.State] for a concrete example.
*/
data class VaultCustomQueryCriteria<L : PersistentState> @JvmOverloads constructor
(val expression: CriteriaExpression<L, Boolean>,

View File

@ -195,6 +195,15 @@ interface SerializationContext {
enum class UseCase { P2P, RPCServer, RPCClient, Storage, Checkpoint, Testing }
}
/**
* Set of well known properties that may be set on a serialization context. This doesn't preclude
* others being set that aren't keyed on this enumeration, but for general use properties adding a
* well known key here is preferred.
*/
enum class ContextPropertyKeys {
SERIALIZERS
}
/**
* Global singletons to be used as defaults that are injected elsewhere (generally, in the node or in RPC client).
*/

View File

@ -16,7 +16,7 @@ package net.corda.core.serialization
* a proxy serializer can be written that extends this type whose purpose is to move between those an
* unserializable types and an intermediate representation.
*
* NOTE: The proxy object should be specified as a seperate class. However, this can be defined within the
* NOTE: The proxy object should be specified as a separate class. However, this can be defined within the
* scope of the custom serializer.
*/
interface SerializationCustomSerializer<OBJ, PROXY> {

View File

@ -12,16 +12,20 @@ package net.corda.core.utilities
import com.esotericsoftware.kryo.KryoException
import net.corda.core.crypto.random63BitValue
import net.corda.core.serialization.CordaSerializable
import net.corda.core.serialization.deserialize
import net.corda.core.serialization.serialize
import net.corda.core.serialization.*
import net.corda.nodeapi.internal.serialization.KRYO_CHECKPOINT_CONTEXT
import net.corda.nodeapi.internal.serialization.SerializationContextImpl
import net.corda.nodeapi.internal.serialization.kryo.kryoMagic
import net.corda.testing.core.SerializationEnvironmentRule
import org.assertj.core.api.Assertions.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
object EmptyWhitelist : ClassWhitelist {
override fun hasListed(type: Class<*>): Boolean = false
}
class KotlinUtilsTest {
@Rule
@JvmField
@ -30,6 +34,14 @@ class KotlinUtilsTest {
@Rule
val expectedEx: ExpectedException = ExpectedException.none()
val KRYO_CHECKPOINT_NOWHITELIST_CONTEXT = SerializationContextImpl(kryoMagic,
SerializationDefaults.javaClass.classLoader,
EmptyWhitelist,
emptyMap(),
true,
SerializationContext.UseCase.Checkpoint,
null)
@Test
fun `transient property which is null`() {
val test = NullTransientProperty()
@ -53,7 +65,8 @@ class KotlinUtilsTest {
expectedEx.expect(KryoException::class.java)
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
val original = NonCapturingTransientProperty()
original.serialize(context = KRYO_CHECKPOINT_CONTEXT.withEncoding(null)).deserialize()
original.serialize(context = KRYO_CHECKPOINT_CONTEXT.withEncoding(null))
.deserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
}
@Test
@ -71,8 +84,10 @@ class KotlinUtilsTest {
fun `deserialise transient property with capturing lambda`() {
expectedEx.expect(KryoException::class.java)
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
val original = CapturingTransientProperty("Hello")
original.serialize(context = KRYO_CHECKPOINT_CONTEXT.withEncoding(null)).deserialize()
original.serialize(context = KRYO_CHECKPOINT_CONTEXT.withEncoding(null))
.deserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
}
private class NullTransientProperty {