CORDA-2782 Add Comparable to default whitelist for vault query criteria using comparables (#4920)

* CORDA-2782 Add Comparable to default whitelist for vault query criteria using comparables

* Commit the java.lang.Comparable type.

* Fix broken unit test in serialization-deterministic
This commit is contained in:
josecoll 2019-03-25 11:59:39 +00:00 committed by GitHub
parent d9a67d7426
commit 12e7897316
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import net.corda.finance.workflows.getCashBalance
import net.corda.finance.workflows.getCashBalances import net.corda.finance.workflows.getCashBalances
import net.corda.finance.flows.CashIssueFlow import net.corda.finance.flows.CashIssueFlow
import net.corda.finance.flows.CashPaymentFlow import net.corda.finance.flows.CashPaymentFlow
import net.corda.finance.schemas.CashSchemaV1
import net.corda.java.rpc.StandaloneCordaRPCJavaClientTest import net.corda.java.rpc.StandaloneCordaRPCJavaClientTest
import net.corda.nodeapi.internal.config.User import net.corda.nodeapi.internal.config.User
import net.corda.smoketesting.NodeConfig import net.corda.smoketesting.NodeConfig
@ -218,6 +219,13 @@ class StandaloneCordaRPClientTest {
log.info("Cash Balances: $cashBalances") log.info("Cash Balances: $cashBalances")
assertEquals(1, cashBalances.size) assertEquals(1, cashBalances.size)
assertEquals(629.POUNDS, cashBalances[Currency.getInstance("GBP")]) assertEquals(629.POUNDS, cashBalances[Currency.getInstance("GBP")])
// Check for cash states using a query criteria comparator
val logicalExpression = builder { CashSchemaV1.PersistentCashState::pennies.greaterThan(10000L) }
val customCriteria = QueryCriteria.VaultCustomQueryCriteria(logicalExpression)
val customCriteriaResults = rpcProxy.vaultQueryBy<Cash.State>(customCriteria)
assertEquals(1, customCriteriaResults.states.size)
assertEquals(customCriteriaResults.states.first().state.data.amount.quantity, 529.POUNDS.quantity)
} }
@Test @Test

View File

@ -6,5 +6,7 @@ import net.corda.core.serialization.SerializationWhitelist
* The DJVM does not need whitelisting, by definition. * The DJVM does not need whitelisting, by definition.
*/ */
object DefaultWhitelist : SerializationWhitelist { object DefaultWhitelist : SerializationWhitelist {
override val whitelist: List<Class<Any>> get() = emptyList() override val whitelist = listOf(
java.lang.Comparable::class.java // required for forwards compatibility with default whitelist
)
} }

View File

@ -63,6 +63,9 @@ object DefaultWhitelist : SerializationWhitelist {
// Implementation of X509Certificate. // Implementation of X509Certificate.
X509CertImpl::class.java, X509CertImpl::class.java,
CRLReason::class.java CRLReason::class.java,
// used in Vault Query criteria comparators (see QueryCriteriaUtils.Builder)
java.lang.Comparable::class.java
) )
} }