Merge remote-tracking branch 'remotes/open/master' into feature/vkolomeyko/corda-os-merge

This commit is contained in:
Viktor Kolomeyko 2018-04-23 14:19:51 +01:00
commit f1fd1cefd8
5 changed files with 77 additions and 12 deletions

View File

@ -9,6 +9,9 @@ Unreleased
* Upgraded H2 to v1.4.197. * Upgraded H2 to v1.4.197.
* Shell (embedded available only in dev mode or via SSH) connects to the node via RPC instead of using the ``CordaRPCOps`` object directly.
To enable RPC connectivity ensure nodes ``rpcSettings.address`` and ``rpcSettings.adminAddress`` settings are present.
* Changes to the network bootstrapper: * Changes to the network bootstrapper:
* The whitelist.txt file is no longer needed. The existing network parameters file is used to update the current contracts * The whitelist.txt file is no longer needed. The existing network parameters file is used to update the current contracts
whitelist. whitelist.
@ -65,7 +68,26 @@ than 2.12.3 (including 2.12.4) exhibit a different issue.
* java.math.BigInteger serialization support added. * java.math.BigInteger serialization support added.
* Fix CORDA-1355: Reduce amount of classpath scanning during integration tests execution.
* java.security.cert.CRLReason added to the default Whitelist. * java.security.cert.CRLReason added to the default Whitelist.
* Fix CORDA-1355: Reduce amount of classpath scanning during integration tests execution.
.. _changelog_v3.1:
Version 3.1
-----------
* Update the fast-classpath-scanner dependent library version from 2.0.21 to 2.12.3
.. note:: Whilst this is not the latest version of this library, that being 2.18.1 at time of writing, versions later
than 2.12.3 (including 2.12.4) exhibit a different issue.
* Updated the api scanner gradle plugin to work the same way as the version in master. These changes make the api scanner more
accurate and fix a couple of bugs, and change the format of the api-current.txt file slightly. Backporting these changes
to the v3 branch will make it easier for us to ensure that apis are stable for future versions. These changes are
released in gradle plugins version 3.0.10. For more information on the api scanner see
the `documentation <https://github.com/corda/corda-gradle-plugins/tree/master/api-scanner>`_.
* java.security.cert.X509CRL serialization support added. * java.security.cert.X509CRL serialization support added.

View File

@ -17,11 +17,16 @@ Custom serializer classes should follow the rules for including classes found in
Writing a Custom Serializer Writing a Custom Serializer
--------------------------- ---------------------------
Serializers must Serializers must
* Inherit from net.corda.core.serialization.SerializationCustomSerializer * Inherit from ``net.corda.core.serialization.SerializationCustomSerializer``
* Provide a proxy class to transform the object to and from * Provide a proxy class to transform the object to and from
* Implement the ``toProxy`` and ``fromProxy`` methods * Implement the ``toProxy`` and ``fromProxy`` methods
* Be either included into CorDapp Jar or made known to the running process via ``amqp.custom.serialization.scanSpec``
system property.
This system property may be necessary to be able to discover custom serializer in the classpath. At a minimum the value
of the property should include comma separated set of packages where custom serializers located. Full syntax includes
scanning specification as defined by: `<http://github.com/lukehutch/fast-classpath-scanner/wiki/2.-Constructor#scan-spec>`
Serializers inheriting from SerializationCustomSerializer have to implement two methods and two types. Serializers inheriting from ``SerializationCustomSerializer`` have to implement two methods and two types.
Example Example
------- -------

View File

@ -51,16 +51,26 @@ abstract class AbstractAMQPSerializationScheme(
// TODO: This method of initialisation for the Whitelist and plugin serializers will have to change // TODO: This method of initialisation for the Whitelist and plugin serializers will have to change
// when we have per-cordapp contexts and dynamic app reloading but for now it's the easiest way // when we have per-cordapp contexts and dynamic app reloading but for now it's the easiest way
companion object { companion object {
const val SCAN_SPEC_PROP_NAME = "amqp.custom.serialization.scanSpec"
private val serializationWhitelists: List<SerializationWhitelist> by lazy { private val serializationWhitelists: List<SerializationWhitelist> by lazy {
ServiceLoader.load(SerializationWhitelist::class.java, this::class.java.classLoader).toList() + DefaultWhitelist ServiceLoader.load(SerializationWhitelist::class.java, this::class.java.classLoader).toList() + DefaultWhitelist
} }
private val customSerializers: List<SerializationCustomSerializer<*, *>> by lazy { private val customSerializers: List<SerializationCustomSerializer<*, *>> by lazy {
FastClasspathScanner().addClassLoader(this::class.java.classLoader).scan()
.getNamesOfClassesImplementing(SerializationCustomSerializer::class.java) val scanSpec: String? = System.getProperty(SCAN_SPEC_PROP_NAME)
.mapNotNull { this::class.java.classLoader.loadClass(it).asSubclass(SerializationCustomSerializer::class.java) }
.filterNot { Modifier.isAbstract(it.modifiers) } if(scanSpec == null) {
.map { it.kotlin.objectOrNewInstance() } emptyList()
} else {
FastClasspathScanner(scanSpec).addClassLoader(this::class.java.classLoader).scan()
.getNamesOfClassesImplementing(SerializationCustomSerializer::class.java)
.mapNotNull { this::class.java.classLoader.loadClass(it).asSubclass(SerializationCustomSerializer::class.java) }
.filterNot { Modifier.isAbstract(it.modifiers) }
.map { it.kotlin.objectOrNewInstance() }
}
} }
} }

View File

@ -12,7 +12,9 @@ package net.corda.vega
import com.opengamma.strata.product.common.BuySell import com.opengamma.strata.product.common.BuySell
import net.corda.core.identity.CordaX500Name import net.corda.core.identity.CordaX500Name
import net.corda.core.internal.packageName
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.nodeapi.internal.serialization.amqp.AbstractAMQPSerializationScheme
import net.corda.testing.core.DUMMY_BANK_A_NAME import net.corda.testing.core.DUMMY_BANK_A_NAME
import net.corda.testing.core.DUMMY_BANK_B_NAME import net.corda.testing.core.DUMMY_BANK_B_NAME
import net.corda.testing.core.DUMMY_NOTARY_NAME import net.corda.testing.core.DUMMY_NOTARY_NAME
@ -26,7 +28,10 @@ import net.corda.vega.api.PortfolioApi
import net.corda.vega.api.PortfolioApiUtils import net.corda.vega.api.PortfolioApiUtils
import net.corda.vega.api.SwapDataModel import net.corda.vega.api.SwapDataModel
import net.corda.vega.api.SwapDataView import net.corda.vega.api.SwapDataView
import net.corda.vega.plugin.customserializers.CurrencyParameterSensitivitiesSerializer
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.ClassRule import org.junit.ClassRule
import org.junit.Test import org.junit.Test
import java.math.BigDecimal import java.math.BigDecimal
@ -46,6 +51,16 @@ class SimmValuationTest : IntegrationTest() {
.map { it.toDatabaseSchemaName() }.toTypedArray()) .map { it.toDatabaseSchemaName() }.toTypedArray())
} }
@Before
fun setup() {
System.setProperty(AbstractAMQPSerializationScheme.SCAN_SPEC_PROP_NAME, CurrencyParameterSensitivitiesSerializer::class.packageName)
}
@After
fun tearDown() {
System.clearProperty(AbstractAMQPSerializationScheme.SCAN_SPEC_PROP_NAME)
}
@Test @Test
fun `runs SIMM valuation demo`() { fun `runs SIMM valuation demo`() {
driver(DriverParameters(isDebug = true, extraCordappPackagesToScan = listOf("net.corda.vega.contracts", "net.corda.vega.plugin.customserializers"))) { driver(DriverParameters(isDebug = true, extraCordappPackagesToScan = listOf("net.corda.vega.contracts", "net.corda.vega.plugin.customserializers"))) {

View File

@ -49,6 +49,7 @@ import net.corda.nodeapi.internal.crypto.X509KeyStore
import net.corda.nodeapi.internal.crypto.X509Utilities import net.corda.nodeapi.internal.crypto.X509Utilities
import net.corda.nodeapi.internal.network.NetworkParametersCopier import net.corda.nodeapi.internal.network.NetworkParametersCopier
import net.corda.nodeapi.internal.network.NodeInfoFilesCopier import net.corda.nodeapi.internal.network.NodeInfoFilesCopier
import net.corda.nodeapi.internal.serialization.amqp.AbstractAMQPSerializationScheme
import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.BOB_NAME import net.corda.testing.core.BOB_NAME
import net.corda.testing.core.DUMMY_BANK_A_NAME import net.corda.testing.core.DUMMY_BANK_A_NAME
@ -761,10 +762,11 @@ class DriverDSLImpl(
val systemProperties = mutableMapOf( val systemProperties = mutableMapOf(
"name" to config.corda.myLegalName, "name" to config.corda.myLegalName,
"visualvm.display.name" to "corda-${config.corda.myLegalName}", "visualvm.display.name" to "corda-${config.corda.myLegalName}",
"java.io.tmpdir" to System.getProperty("java.io.tmpdir"), // Inherit from parent process
"log4j2.debug" to if (debugPort != null) "true" else "false" "log4j2.debug" to if (debugPort != null) "true" else "false"
) )
systemProperties += inheritFromParentProcess()
if (cordappPackages.isNotEmpty()) { if (cordappPackages.isNotEmpty()) {
systemProperties += Node.scanPackagesSystemProperty to cordappPackages.joinToString(Node.scanPackagesSeparator) systemProperties += Node.scanPackagesSystemProperty to cordappPackages.joinToString(Node.scanPackagesSeparator)
} }
@ -808,15 +810,26 @@ class DriverDSLImpl(
className = className, // cannot directly get class for this, so just use string className = className, // cannot directly get class for this, so just use string
arguments = listOf("--base-directory", handle.baseDirectory.toString()), arguments = listOf("--base-directory", handle.baseDirectory.toString()),
jdwpPort = debugPort, jdwpPort = debugPort,
extraJvmArguments = listOf( extraJvmArguments = listOf("-Dname=node-${handle.p2pAddress}-webserver") +
"-Dname=node-${handle.p2pAddress}-webserver", inheritFromParentProcess().map { "-D${it.first}=${it.second}" },
"-Djava.io.tmpdir=${System.getProperty("java.io.tmpdir")}" // Inherit from parent process
),
workingDirectory = null, workingDirectory = null,
maximumHeapSize = maximumHeapSize maximumHeapSize = maximumHeapSize
) )
} }
private val propertiesInScope = setOf("java.io.tmpdir", AbstractAMQPSerializationScheme.SCAN_SPEC_PROP_NAME)
private fun inheritFromParentProcess() : Iterable<Pair<String, String>> {
return propertiesInScope.flatMap { propName ->
val propValue : String? = System.getProperty(propName)
if(propValue == null) {
emptySet()
} else {
setOf(Pair(propName, propValue))
}
}
}
private fun NodeHandleInternal.toWebServerConfig(): Config { private fun NodeHandleInternal.toWebServerConfig(): Config {
var config = ConfigFactory.empty() var config = ConfigFactory.empty()