From 0cbee046f9b06aed66b749978399346322ab6531 Mon Sep 17 00:00:00 2001 From: Christian Sailer Date: Thu, 26 Oct 2017 14:36:24 +0100 Subject: [PATCH] Add extension method to check for flags devModeOptions, formatting --- .../statemachine/StateMachineManagerImpl.kt | 4 ++-- .../services/config/FullNodeConfigurationTest.kt | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManagerImpl.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManagerImpl.kt index cf96c9a0d2..be4f991313 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManagerImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/StateMachineManagerImpl.kt @@ -31,6 +31,7 @@ import net.corda.node.internal.InitiatedFlowFactory import net.corda.node.services.api.Checkpoint import net.corda.node.services.api.CheckpointStorage import net.corda.node.services.api.ServiceHubInternal +import net.corda.node.services.config.isDevModeOptionsFlagSet import net.corda.node.services.messaging.ReceivedMessage import net.corda.node.services.messaging.TopicSession import net.corda.node.utilities.* @@ -43,7 +44,6 @@ import rx.subjects.PublishSubject import java.io.NotSerializableException import java.util.* import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.Executors import java.util.concurrent.TimeUnit.SECONDS import javax.annotation.concurrent.ThreadSafe @@ -89,7 +89,7 @@ class StateMachineManagerImpl( private val scheduler = FiberScheduler() private val mutex = ThreadBox(InnerState()) // This thread (only enabled in dev mode) deserialises checkpoints in the background to shake out bugs in checkpoint restore. - private val checkpointCheckerThread = if (serviceHub.configuration.devMode && serviceHub.configuration.debugOptions?.getProperty("disableCheckpointChecking") != "true") newNamedSingleThreadExecutor("CheckpointChecker") else null + private val checkpointCheckerThread = if (serviceHub.configuration.devMode && !serviceHub.configuration.isDevModeOptionsFlagSet("disableCheckpointChecking")) newNamedSingleThreadExecutor("CheckpointChecker") else null @Volatile private var unrestorableCheckpoints = false diff --git a/node/src/test/kotlin/net/corda/node/services/config/FullNodeConfigurationTest.kt b/node/src/test/kotlin/net/corda/node/services/config/FullNodeConfigurationTest.kt index 8a5ca1547c..db1a61b6fb 100644 --- a/node/src/test/kotlin/net/corda/node/services/config/FullNodeConfigurationTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/config/FullNodeConfigurationTest.kt @@ -71,17 +71,17 @@ class FullNodeConfigurationTest { additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis()) fun configDebugOptions(devMode: Boolean, debugOptions: Properties?) { - testConfiguration.copy(devMode = devMode, debugOptions = debugOptions) + testConfiguration.copy(devMode = devMode, devModeOptions = debugOptions) } val debugOptions = Properties() configDebugOptions(true, debugOptions) configDebugOptions(true,null) - assertThatThrownBy{configDebugOptions(false, debugOptions)}.hasMessageMatching("Cannot use debugOptions outside of dev mode") + assertThatThrownBy{configDebugOptions(false, debugOptions)}.hasMessageMatching( "Cannot use devModeOptions outside of dev mode" ) configDebugOptions(false,null) } @Test - fun `check properties behave as expected`() + fun `check devModeOptions flag helper`() { val testConfiguration = FullNodeConfiguration( baseDirectory = Paths.get("."), @@ -106,13 +106,13 @@ class FullNodeConfigurationTest { additionalNodeInfoPollingFrequencyMsec = 5.seconds.toMillis()) fun configDebugOptions(devMode: Boolean, debugOptions: Properties?) : NodeConfiguration { - return testConfiguration.copy(devMode = devMode, debugOptions = debugOptions) + return testConfiguration.copy(devMode = devMode, devModeOptions = debugOptions) } val debugOptions = Properties() - assertFalse { configDebugOptions(true, debugOptions).debugOptions?.getProperty("foo") == "bar"} - assertFalse { configDebugOptions(true,null).debugOptions?.getProperty("foo") == "bar"} - debugOptions.setProperty("foo", "bar") - assert( configDebugOptions(true, debugOptions).debugOptions?.getProperty("foo") == "bar") + assertFalse { configDebugOptions(true,null).isDevModeOptionsFlagSet("foo")} + assertFalse { configDebugOptions(true,debugOptions).isDevModeOptionsFlagSet("foo")} + debugOptions.setProperty("foo", "tRuE") + assert( configDebugOptions(true, debugOptions).isDevModeOptionsFlagSet("foo")) } }