diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/GeneratorParameters.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/GeneratorParameters.kt index a12c5a442b..4edf893e20 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/GeneratorParameters.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/generator/GeneratorParameters.kt @@ -90,5 +90,5 @@ fun parseParameters(configFile: Path): GeneratorParameters { return ConfigFactory .parseFile(configFile.toFile(), ConfigParseOptions.defaults().setAllowMissing(true)) .resolve() - .parseAs() + .parseAs(false) } \ No newline at end of file diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/config/ConfigUtilities.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/config/ConfigUtilities.kt index f3b91016d0..8fbdb464d8 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/config/ConfigUtilities.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/config/ConfigUtilities.kt @@ -62,7 +62,7 @@ fun Config.parseAs(clazz: KClass, strict: Boolean = true): T { // Get the matching property for this parameter val property = clazz.memberProperties.first { it.name == param.name } val path = defaultToOldPath(property) - getValueInternal(path, param.type) + getValueInternal(path, param.type, strict) } return constructor.callBy(args) } @@ -90,11 +90,11 @@ fun Config.toProperties(): Properties { { it.value.unwrapped().toString() }) } -private fun Config.getValueInternal(path: String, type: KType): T { - return uncheckedCast(if (type.arguments.isEmpty()) getSingleValue(path, type) else getCollectionValue(path, type)) +private fun Config.getValueInternal(path: String, type: KType, strict: Boolean = true): T { + return uncheckedCast(if (type.arguments.isEmpty()) getSingleValue(path, type, strict) else getCollectionValue(path, type, strict)) } -private fun Config.getSingleValue(path: String, type: KType): Any? { +private fun Config.getSingleValue(path: String, type: KType, strict: Boolean = true): Any? { if (type.isMarkedNullable && !hasPath(path)) return null val typeClass = type.jvmErasure return when (typeClass) { @@ -110,7 +110,7 @@ private fun Config.getSingleValue(path: String, type: KType): Any? { URL::class -> URL(getString(path)) CordaX500Name::class -> { when (getValue(path).valueType()) { - ConfigValueType.OBJECT -> getConfig(path).parseAs() + ConfigValueType.OBJECT -> getConfig(path).parseAs(strict) else -> CordaX500Name.parse(getString(path)) } } @@ -119,12 +119,12 @@ private fun Config.getSingleValue(path: String, type: KType): Any? { else -> if (typeClass.java.isEnum) { parseEnum(typeClass.java, getString(path)) } else { - getConfig(path).parseAs(typeClass) + getConfig(path).parseAs(typeClass, strict) } } } -private fun Config.getCollectionValue(path: String, type: KType): Collection { +private fun Config.getCollectionValue(path: String, type: KType, strict: Boolean = true): Collection { val typeClass = type.jvmErasure require(typeClass == List::class || typeClass == Set::class) { "$typeClass is not supported" } val elementClass = type.arguments[0].type?.jvmErasure ?: throw IllegalArgumentException("Cannot work with star projection: $type") @@ -147,7 +147,7 @@ private fun Config.getCollectionValue(path: String, type: KType): Collection if (elementClass.java.isEnum) { getStringList(path).map { parseEnum(elementClass.java, it) } } else { - getConfigList(path).map { it.parseAs(elementClass) } + getConfigList(path).map { it.parseAs(elementClass, strict) } } } return if (typeClass == Set::class) values.toSet() else values