From d3cdb2af67e0a7cb9211c7639f904553de7bbf32 Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Wed, 8 Feb 2017 14:24:13 +0000 Subject: [PATCH] Force all chosen port numbers to be different. --- .../net/corda/demobench/views/NodeTabView.kt | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt index b196bb1a8a..962385a794 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTabView.kt @@ -73,10 +73,17 @@ class NodeTabView : Fragment() { error("Port number required") } else if (it.contains(NOT_NUMBER)) { error("Invalid port number") - } else if (!nodeController.isPortAvailable(it.toInt())) { - error("Port $it is unavailable") } else { - null + val port = it.toInt() + if (!nodeController.isPortAvailable(port)) { + error("Port $it is unavailable") + } else if (port == model.webPort.value) { + error("Clashes with web port") + } else if (port == model.h2Port.value) { + error("Clashes with database port") + } else { + null + } } } } @@ -90,10 +97,17 @@ class NodeTabView : Fragment() { error("Port number required") } else if (it.contains(NOT_NUMBER)) { error("Invalid port number") - } else if (!nodeController.isPortAvailable(it.toInt())) { - error("Port $it is unavailable") } else { - null + val port = it.toInt() + if (!nodeController.isPortAvailable(port)) { + error("Port $it is unavailable") + } else if (port == model.artemisPort.value) { + error("Clashes with P2P port") + } else if (port == model.h2Port.value) { + error("Clashes with database port") + } else { + null + } } } } @@ -107,10 +121,17 @@ class NodeTabView : Fragment() { error("Port number required") } else if (it.contains(NOT_NUMBER)) { error("Invalid port number") - } else if (!nodeController.isPortAvailable(it.toInt())) { - error("Port $it is unavailable") } else { - null + val port = it.toInt() + if (!nodeController.isPortAvailable(port)) { + error("Port $it is unavailable") + } else if (port == model.artemisPort.value) { + error("Clashes with P2P port") + } else if (port == model.webPort.value) { + error("Clashes with web port") + } else { + null + } } } }