diff --git a/node/src/integration-test/kotlin/net/corda/node/persistence/DbSchemaInitialisationTest.kt b/node/src/integration-test/kotlin/net/corda/node/persistence/DbSchemaInitialisationTest.kt index 101bf9c0f7..9b848400fd 100644 --- a/node/src/integration-test/kotlin/net/corda/node/persistence/DbSchemaInitialisationTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/persistence/DbSchemaInitialisationTest.kt @@ -2,7 +2,6 @@ package net.corda.node.persistence import net.corda.core.utilities.getOrThrow import net.corda.node.flows.isQuasarAgentSpecified -import net.corda.node.internal.ConfigurationException import net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException import net.corda.nodeapi.internal.persistence.HibernateSchemaChangeException import net.corda.testing.core.ALICE_NAME @@ -10,16 +9,16 @@ import net.corda.testing.driver.DriverParameters import net.corda.testing.driver.NodeParameters import net.corda.testing.driver.driver import net.corda.testing.node.TestCordapp -import org.junit.Test import net.corda.testing.node.internal.startNode import org.assertj.core.api.Assertions.assertThatExceptionOfType +import org.junit.Test import kotlin.test.assertFailsWith class DbSchemaInitialisationTest { @Test(timeout = 300_000) fun `database initialisation not allowed in config`() { driver(DriverParameters(startNodesInProcess = isQuasarAgentSpecified(), cordappsForAllNodes = emptyList())) { - assertFailsWith(ConfigurationException::class) { + assertFailsWith(IllegalStateException::class) { startNode(NodeParameters(customOverrides = mapOf("database.initialiseSchema" to "false"))).getOrThrow() } } diff --git a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt index 19b289df98..6b33dcf882 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/schema/v1/ConfigSections.kt @@ -14,7 +14,6 @@ import net.corda.common.validation.internal.Validated.Companion.invalid import net.corda.common.validation.internal.Validated.Companion.valid import net.corda.core.context.AuthServiceId import net.corda.core.internal.notary.NotaryServiceFlow -import net.corda.node.internal.ConfigurationException import net.corda.node.services.config.AuthDataSourceType import net.corda.node.services.config.CertChainPolicyConfig import net.corda.node.services.config.CertChainPolicyType @@ -281,17 +280,26 @@ internal object DatabaseConfigSpec : Configuration.Specification private val mappedSchemaCacheSize by long().optional().withDefaultValue(DatabaseConfig.Defaults.mappedSchemaCacheSize) override fun parseValid(configuration: Config, options: Configuration.Options): Valid { - if (initialiseSchema.isSpecifiedBy(configuration)){ - throw ConfigurationException("Unsupported configuration database/initialiseSchema - this option has been removed, please use the run-migration-scripts sub-command or the database management tool to modify schemas") + if (initialiseSchema.isSpecifiedBy(configuration)) { + return invalid(Configuration.Validation.Error.BadPath.of( + "Unsupported configuration database/initialiseSchema - this option has been removed, please use the run-migration-scripts sub-command or the database management tool to modify schemas", + "initialiseSchema", + "Boolean")) } - if (initialiseAppSchema.isSpecifiedBy(configuration)){ - throw ConfigurationException("Unsupported configuration database/initialiseAppSchema - this option has been removed, please use the run-migration-scripts sub-command or the database management tool to modify schemas") + if (initialiseAppSchema.isSpecifiedBy(configuration)) { + return invalid(Configuration.Validation.Error.BadPath.of( + "Unsupported configuration database/initialiseAppSchema - this option has been removed, please use the run-migration-scripts sub-command or the database management tool to modify schemas", + "initialiseAppSchema", + SchemaInitializationType::class.qualifiedName!!)) } - if (transactionIsolationLevel.isSpecifiedBy(configuration)){ - throw ConfigurationException("Unsupported configuration database/transactionIsolationLevel - this option has been removed and cannot be changed") + if (transactionIsolationLevel.isSpecifiedBy(configuration)) { + return invalid(Configuration.Validation.Error.BadPath.of( + "Unsupported configuration database/transactionIsolationLevel - this option has been removed and cannot be changed", + "transactionIsolationLevel", + TransactionIsolationLevel::class.qualifiedName!!)) } - val config = configuration.withOptions(options) + val config = configuration.withOptions(options) return valid(DatabaseConfig(config[exportHibernateJMXStatistics], config[mappedSchemaCacheSize])) } }