Fix node crash when the plugins dir is empty

This commit is contained in:
Shams Asari 2017-05-11 17:50:18 +01:00
parent 6d1462f8eb
commit 8cb7c5eab1
2 changed files with 24 additions and 0 deletions

View File

@ -325,6 +325,8 @@ abstract class AbstractNode(open val configuration: NodeConfiguration,
it.filter { it.isRegularFile() && it.toString().endsWith(".jar") }.toArray()
}
if (pluginJars.isEmpty()) return emptyList()
val scanResult = FastClasspathScanner().overrideClasspath(*pluginJars).scan() // This will only scan the plugin jars and nothing else
fun loadFlowClass(className: String): Class<out FlowLogic<*>>? {

View File

@ -0,0 +1,22 @@
package net.corda.node.internal
import net.corda.core.createDirectories
import net.corda.core.crypto.commonName
import net.corda.core.div
import net.corda.core.getOrThrow
import net.corda.core.utilities.ALICE
import net.corda.testing.node.NodeBasedTest
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
class NodeTest : NodeBasedTest() {
@Test
fun `empty plugins directory`() {
val baseDirectory = tempFolder.root.toPath() / ALICE.name.commonName
(baseDirectory / "plugins").createDirectories()
val node = startNode(ALICE.name).getOrThrow()
// Make sure we created the plugins dir in the correct place
assertThat(baseDirectory).isEqualTo(node.configuration.baseDirectory)
}
}