From f2b6f96486973fdff25abcd9e21591484ca26d32 Mon Sep 17 00:00:00 2001 From: Michele Sollecito Date: Fri, 14 Dec 2018 13:18:01 +0000 Subject: [PATCH] Fixed an issue with the port allocation. (#4418) --- .../internal/GlobalTestPortAllocation.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/internal/GlobalTestPortAllocation.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/internal/GlobalTestPortAllocation.kt index 3a1247446f..b6736bd5f0 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/internal/GlobalTestPortAllocation.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/internal/GlobalTestPortAllocation.kt @@ -1,10 +1,6 @@ package net.corda.testing.driver.internal import net.corda.testing.driver.PortAllocation -import net.corda.testing.driver.internal.GlobalTestPortAllocation.enablingEnvVar -import net.corda.testing.driver.internal.GlobalTestPortAllocation.enablingSystemProperty -import net.corda.testing.driver.internal.GlobalTestPortAllocation.startingPortEnvVariable -import net.corda.testing.driver.internal.GlobalTestPortAllocation.startingPortSystemProperty fun incrementalPortAllocation(startingPortIfNoEnv: Int): PortAllocation { @@ -14,13 +10,16 @@ fun incrementalPortAllocation(startingPortIfNoEnv: Int): PortAllocation { } } -private object GlobalTestPortAllocation : PortAllocation.Incremental(startingPort = startingPort) { +private object GlobalTestPortAllocation : PortAllocation.Incremental(startingPort = startingPort()) - const val enablingEnvVar = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_ENABLED" - const val startingPortEnvVariable = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_STARTING_PORT" - val enablingSystemProperty = enablingEnvVar.toLowerCase().replace("_", ".") - val startingPortSystemProperty = startingPortEnvVariable.toLowerCase().replace("_", ".") - const val startingPortDefaultValue = 5000 -} +private const val enablingEnvVar = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_ENABLED" +private const val startingPortEnvVariable = "CORDA_TEST_GLOBAL_PORT_ALLOCATION_STARTING_PORT" +private val enablingSystemProperty = enablingEnvVar.toLowerCase().replace("_", ".") +private val startingPortSystemProperty = startingPortEnvVariable.toLowerCase().replace("_", ".") +private const val startingPortDefaultValue = 5000 -private val startingPort: Int = System.getProperty(startingPortSystemProperty)?.toIntOrNull() ?: System.getenv(startingPortEnvVariable)?.toIntOrNull() ?: GlobalTestPortAllocation.startingPortDefaultValue \ No newline at end of file + +private fun startingPort(): Int { + + return System.getProperty(startingPortSystemProperty)?.toIntOrNull() ?: System.getenv(startingPortEnvVariable)?.toIntOrNull() ?: startingPortDefaultValue +} \ No newline at end of file