[CORDA-926]: Parsing NodeConfiguration will now fail if unknown properties are present. (#2484)

This commit is contained in:
Michele Sollecito
2018-03-01 14:57:36 +00:00
committed by GitHub
parent 754b87d547
commit b580a2ac30
26 changed files with 278 additions and 86 deletions

View File

@ -82,14 +82,14 @@ class AuthDBTests : NodeBasedTest() {
"password" to "",
"driverClassName" to "org.h2.Driver"
)
),
"options" to mapOf(
"cache" to mapOf(
"expireAfterSecs" to cacheExpireAfterSecs,
"maxEntries" to 50
)
)
),
"options" to mapOf(
"cache" to mapOf(
"expireAfterSecs" to cacheExpireAfterSecs,
"maxEntries" to 50
)
)
)
)
)

View File

@ -100,7 +100,7 @@ public class CordaCaplet extends Capsule {
// Read JVM args from the config if specified, else leave alone.
List<String> jvmArgs = new ArrayList<>((List<String>) super.attribute(attr));
try {
List<String> configJvmArgs = nodeConfig.getStringList("jvmArgs");
List<String> configJvmArgs = nodeConfig.getStringList("custom.jvmArgs");
jvmArgs.clear();
jvmArgs.addAll(configJvmArgs);
log(LOG_VERBOSE, "Configured JVM args = " + jvmArgs);

View File

@ -17,6 +17,7 @@ import net.corda.node.shell.InteractiveShell
import net.corda.node.utilities.registration.HTTPNetworkRegistrationService
import net.corda.node.utilities.registration.NetworkRegistrationHelper
import net.corda.nodeapi.internal.addShutdownHook
import net.corda.nodeapi.internal.config.UnknownConfigurationKeysException
import org.fusesource.jansi.Ansi
import org.fusesource.jansi.AnsiConsole
import org.slf4j.bridge.SLF4JBridgeHandler
@ -86,6 +87,9 @@ open class NodeStartup(val args: Array<String>) {
} else {
conf0
}
} catch (e: UnknownConfigurationKeysException) {
logger.error(e.message)
return false
} catch (e: Exception) {
logger.error("Exception during node configuration", e)
return false

View File

@ -150,7 +150,9 @@ data class NodeConfigurationImpl(
override val database: DatabaseConfig = DatabaseConfig(initialiseSchema = devMode, exportHibernateJMXStatistics = devMode),
private val transactionCacheSizeMegaBytes: Int? = null,
private val attachmentContentCacheSizeMegaBytes: Int? = null,
override val attachmentCacheBound: Long = NodeConfiguration.defaultAttachmentCacheBound
override val attachmentCacheBound: Long = NodeConfiguration.defaultAttachmentCacheBound,
// do not use or remove (breaks DemoBench together with rejection of unknown configuration keys during parsing)
private val h2port: Int = 0
) : NodeConfiguration {
companion object {
private val logger = loggerFor<NodeConfigurationImpl>()