mirror of
https://github.com/corda/corda.git
synced 2025-01-22 04:18:31 +00:00
Fixed a bug in the CorDapp loader that crashed when plugins were loaded (#1527)
* Fixed a bug in the CorDapp loader that crashed when plugins were loaded due to an incorrect classloader definition. * Removed debug statement.
This commit is contained in:
parent
f6bfca8c8e
commit
64f2bf7b09
@ -0,0 +1,8 @@
|
||||
package net.corda.finance.contracts.isolated
|
||||
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
|
||||
/**
|
||||
* Dummy plugin for testing plugin loading
|
||||
*/
|
||||
class DummyPlugin : CordaPluginRegistry()
|
@ -0,0 +1 @@
|
||||
net.corda.finance.contracts.isolated.DummyPlugin
|
@ -134,7 +134,9 @@ class CordappLoader private constructor(private val cordappJarPaths: List<URL>)
|
||||
}
|
||||
|
||||
private fun findPlugins(cordappJarPath: URL): List<CordaPluginRegistry> {
|
||||
return ServiceLoader.load(CordaPluginRegistry::class.java, URLClassLoader(arrayOf(cordappJarPath), null)).toList()
|
||||
return ServiceLoader.load(CordaPluginRegistry::class.java, URLClassLoader(arrayOf(cordappJarPath), appClassLoader)).toList().filter {
|
||||
cordappJarPath == it.javaClass.protectionDomain.codeSource.location
|
||||
}
|
||||
}
|
||||
|
||||
private fun findCustomSchemas(scanResult: ScanResult): Set<MappedSchema> {
|
||||
|
@ -35,18 +35,20 @@ class CordappLoaderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isolated JAR contains a CorDapp with a contract`() {
|
||||
fun `isolated JAR contains a CorDapp with a contract and plugin`() {
|
||||
val isolatedJAR = CordappLoaderTest::class.java.getResource("isolated.jar")!!
|
||||
val loader = CordappLoader.createDevMode(listOf(isolatedJAR))
|
||||
val expectedCordapp = Cordapp(
|
||||
listOf("net.corda.finance.contracts.isolated.AnotherDummyContract"),
|
||||
emptyList(),
|
||||
listOf(loader.appClassLoader.loadClass("net.corda.core.flows.ContractUpgradeFlow\$Initiator").asSubclass(FlowLogic::class.java)),
|
||||
emptyList(),
|
||||
emptyList(),
|
||||
emptySet(),
|
||||
isolatedJAR)
|
||||
val expected = arrayOf(expectedCordapp)
|
||||
Assert.assertArrayEquals(expected, loader.cordapps.toTypedArray())
|
||||
|
||||
val actual = loader.cordapps.toTypedArray()
|
||||
assertThat(actual).hasSize(1)
|
||||
|
||||
val actualCordapp = actual.first()
|
||||
assertThat(actualCordapp.contractClassNames).isEqualTo(listOf("net.corda.finance.contracts.isolated.AnotherDummyContract"))
|
||||
assertThat(actualCordapp.initiatedFlows).isEmpty()
|
||||
assertThat(actualCordapp.rpcFlows).isEqualTo(listOf(loader.appClassLoader.loadClass("net.corda.core.flows.ContractUpgradeFlow\$Initiator").asSubclass(FlowLogic::class.java)))
|
||||
assertThat(actualCordapp.services).isEmpty()
|
||||
assertThat(actualCordapp.plugins).hasSize(1)
|
||||
assertThat(actualCordapp.plugins.first().javaClass.name).isEqualTo("net.corda.finance.contracts.isolated.DummyPlugin")
|
||||
assertThat(actualCordapp.jarPath).isEqualTo(isolatedJAR)
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user