From 128d5cad0af7fc5595cac3287650663c9c9ac0a3 Mon Sep 17 00:00:00 2001 From: "Molina Atienza, Rose" Date: Thu, 21 Sep 2017 08:21:34 +0100 Subject: [PATCH 1/3] Fixed typo in KotlinUtils.kt seperate -> separate --- core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt b/core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt index b12ea8353d..dd76afb644 100644 --- a/core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt +++ b/core/src/main/kotlin/net/corda/core/utilities/KotlinUtils.kt @@ -14,7 +14,7 @@ import kotlin.reflect.KProperty // READ ME FIRST: // This is a collection of public utilities useful only for Kotlin code. Think carefully before adding anything here and // make sure it's tested and documented. If you're looking to add a public utility that is also relevant to Java then -// don't put it here but in a seperate file called Utils.kt +// don't put it here but in a separate file called Utils.kt // /** Like the + operator but throws [ArithmeticException] in case of integer overflow. */ From 857e3954390e7f2f3165107d0475545aed39a38d Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Fri, 17 Nov 2017 15:31:59 +0000 Subject: [PATCH 2/3] Change how mock notary identity is extracted (#2075) Change how mock notary identity is extracted, to match reversion in commit 3bb018a5 --- .../src/main/kotlin/net/corda/testing/node/MockNode.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt index a959fd87ec..588eed3711 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockNode.kt @@ -169,7 +169,7 @@ class MockNetwork(defaultParameters: MockNetworkParameters = MockNetworkParamete * @see defaultNotaryNode */ val defaultNotaryIdentityAndCert: PartyAndCertificate get() { - return defaultNotaryNode.info.legalIdentitiesAndCerts.singleOrNull() ?: throw IllegalStateException("Default notary has multiple identities") + return defaultNotaryNode.info.legalIdentitiesAndCerts[1] // TODO Resolve once network parameters is merged back in } /** From 817748c87ed1ad1b8b345c534825c5861f8e1da9 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Fri, 17 Nov 2017 15:35:05 +0000 Subject: [PATCH 3/3] Performance improvement: cache app classloaders (#2060) Cache results of the classpath scanning for cordapps --- .../corda/node/internal/cordapp/CordappLoader.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappLoader.kt b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappLoader.kt index 50daaa1d8d..025d0bc94e 100644 --- a/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappLoader.kt +++ b/node/src/main/kotlin/net/corda/node/internal/cordapp/CordappLoader.kt @@ -16,6 +16,7 @@ import net.corda.core.utilities.loggerFor import net.corda.node.internal.classloading.requireAnnotation import net.corda.node.services.config.NodeConfiguration import net.corda.nodeapi.internal.serialization.DefaultWhitelist +import org.apache.commons.collections4.map.LRUMap import java.io.File import java.io.FileOutputStream import java.lang.reflect.Modifier @@ -67,6 +68,9 @@ class CordappLoader private constructor(private val cordappJarPaths: List, CordappLoader>(1000) + /** * Create a dev mode CordappLoader for test environments that creates and loads cordapps from the classpath * and cordapps directory. This is intended mostly for use by the driver. @@ -77,7 +81,8 @@ class CordappLoader private constructor(private val cordappJarPaths: List): CordappLoader { check(configuration.devMode) { "Package scanning can only occur in dev mode" } - return CordappLoader(getCordappsInDirectory(getCordappsPath(configuration.baseDirectory)) + testPackages.flatMap(this::createScanPackage)) + val paths = getCordappsInDirectory(getCordappsPath(configuration.baseDirectory)) + testPackages.flatMap(this::createScanPackage) + return cordappLoadersCache.computeIfAbsent(paths, { CordappLoader(paths) }) } /** @@ -89,7 +94,7 @@ class CordappLoader private constructor(private val cordappJarPaths: List) - = CordappLoader(testPackages.flatMap(this::createScanPackage)) + = cordappLoadersCache.computeIfAbsent(testPackages, { CordappLoader(testPackages.flatMap(this::createScanPackage)) }) /** * Creates a dev mode CordappLoader intended only to be used in test environments @@ -242,9 +247,12 @@ class CordappLoader private constructor(private val cordappJarPaths: List(1000) private fun scanCordapp(cordappJarPath: RestrictedURL): RestrictedScanResult { logger.info("Scanning CorDapp in $cordappJarPath") - return RestrictedScanResult(FastClasspathScanner().addClassLoader(appClassLoader).overrideClasspath(cordappJarPath.url).scan(), cordappJarPath.qualifiedNamePrefix) + return cachedScanResult.computeIfAbsent(cordappJarPath, { + RestrictedScanResult(FastClasspathScanner().addClassLoader(appClassLoader).overrideClasspath(cordappJarPath.url).scan(), cordappJarPath.qualifiedNamePrefix) + }) } private class FlowTypeHierarchyComparator(val initiatingFlow: Class>) : Comparator>> {