From 4ae8356f35e4db1c531ddd07088a7def416678d8 Mon Sep 17 00:00:00 2001 From: Clinton Alexander Date: Thu, 1 Jun 2017 15:46:32 +0100 Subject: [PATCH] Reordered a lazy eval to avoid an NPE --- constants.properties | 2 +- .../kotlin/net/corda/plugins/NodeRunner.kt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/constants.properties b/constants.properties index 29575b5763..975d27b7a1 100644 --- a/constants.properties +++ b/constants.properties @@ -1,4 +1,4 @@ -gradlePluginsVersion=0.12.2 +gradlePluginsVersion=0.12.3 kotlinVersion=1.1.2 guavaVersion=21.0 bouncycastleVersion=1.56 diff --git a/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt b/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt index e8f39c7f8c..bc2d9181a0 100644 --- a/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt +++ b/gradle-plugins/cordformation/src/noderunner/kotlin/net/corda/plugins/NodeRunner.kt @@ -64,6 +64,13 @@ private object WebJarType : JarType("corda-webserver.jar") { } private abstract class JavaCommand(jarName: String, internal val dir: File, debugPort: Int?, internal val nodeName: String, init: MutableList.() -> Unit, args: List) { + private val javaPath: String by lazy { + val path = File(File(System.getProperty("java.home"), "bin"), "java").path + // Replace below is to fix an issue with spaces in paths on Windows. + // Quoting the entire path does not work, only the space or directory within the path. + if(os == OS.WINDOWS) path.replace(" ", "\" \"") else path + } + internal val command: List = mutableListOf().apply { add(javaPath) add("-Dname=$nodeName") @@ -76,13 +83,6 @@ private abstract class JavaCommand(jarName: String, internal val dir: File, debu internal abstract fun processBuilder(): ProcessBuilder internal fun start() = processBuilder().directory(dir).start() - - private val javaPath: String by lazy { - val path = File(File(System.getProperty("java.home"), "bin"), "java").path - // Replace below is to fix an issue with spaces in paths on Windows. - // Quoting the entire path does not work, only the space or directory within the path. - if(os == OS.WINDOWS) path.replace(" ", "\" \"") else path - } } private class HeadlessJavaCommand(jarName: String, dir: File, debugPort: Int?, args: List) : JavaCommand(jarName, dir, debugPort, dir.name, { add("--no-local-shell") }, args) {