mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
CORDA-1670 fix multiple CorDapps for flow check (#3436)
* CORDA-1670 fix multiple CorDapps for flow check * CORDA-1670 fix multiple CorDapps for flow check * CORDA-1670 address code review comment
This commit is contained in:
parent
1d95ffba3a
commit
4ea8091667
@ -15,6 +15,7 @@ import net.corda.node.NodeRegistrationOption
|
||||
import net.corda.node.SerialFilter
|
||||
import net.corda.node.VersionInfo
|
||||
import net.corda.node.defaultSerialFilter
|
||||
import net.corda.node.internal.cordapp.MultipleCordappsForFlowException
|
||||
import net.corda.node.services.config.NodeConfiguration
|
||||
import net.corda.node.services.config.NodeConfigurationImpl
|
||||
import net.corda.node.services.config.shouldStartLocalShell
|
||||
@ -135,6 +136,9 @@ open class NodeStartup(val args: Array<String>) {
|
||||
try {
|
||||
cmdlineOptions.baseDirectory.createDirectories()
|
||||
startNode(conf, versionInfo, startTime, cmdlineOptions)
|
||||
} catch (e: MultipleCordappsForFlowException) {
|
||||
logger.error(e.message)
|
||||
return false
|
||||
} catch (e: CouldNotCreateDataSourceException) {
|
||||
logger.error(e.message, e.cause)
|
||||
return false
|
||||
|
@ -50,7 +50,7 @@ class CordappLoader private constructor(private val cordappJarPaths: List<Restri
|
||||
cordapps.flatMap { corDapp -> corDapp.allFlows.map { flow -> flow to corDapp } }
|
||||
.groupBy { it.first }
|
||||
.mapValues {
|
||||
require(it.value.size == 1) { "There are multiple CorDapp jars on the classpath for flow ${it.value.first().first.name}: ${it.value.map { it.second.name }.joinToString()}." }
|
||||
if(it.value.size > 1) { throw MultipleCordappsForFlowException("There are multiple CorDapp JARs on the classpath for flow ${it.value.first().first.name}: [ ${it.value.joinToString { it.second.name }} ].") }
|
||||
it.value.single().second
|
||||
}
|
||||
}
|
||||
@ -363,3 +363,8 @@ class CordappLoader private constructor(private val cordappJarPaths: List<Restri
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when scanning CorDapps.
|
||||
*/
|
||||
class MultipleCordappsForFlowException(message: String) : Exception(message)
|
||||
|
@ -41,6 +41,9 @@ open class CordappProviderImpl(private val cordappLoader: CordappLoader,
|
||||
|
||||
private fun verifyInstalledCordapps(attachmentStorage: AttachmentStorage) {
|
||||
|
||||
// This will invoke the lazy flowCordappMap property, thus triggering the MultipleCordappsForFlow check.
|
||||
cordappLoader.flowCordappMap
|
||||
|
||||
if (whitelistedContractImplementations.isEmpty()) {
|
||||
log.warn("The network parameters don't specify any whitelisted contract implementations. Please contact your zone operator. See https://docs.corda.net/network-map.html")
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user