From da192bcf0d992e8ac64dfc8a2131a2f49b064a20 Mon Sep 17 00:00:00 2001 From: James Higgs <45565019+JamesHR3@users.noreply.github.com> Date: Fri, 14 Feb 2020 11:18:21 +0000 Subject: [PATCH] [EG-140] Allow system property paths with multiple keys to be specified in node.conf (#5963) * [EG-140] Allow system property paths with multiple keys to be specified in node.conf * [EG-140] Split property paths to remove quotes * [EG-140] Quote system properties in docs * [EG-140] Rename path to key --- docs/source/corda-configuration-file.rst | 2 +- node/capsule/src/main/java/CordaCaplet.java | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index bfe4c781ce..a8f80f2834 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -643,7 +643,7 @@ sshd systemProperties An optional map of additional system properties to be set when launching via ``corda.jar`` only. - Keys and values of the map should be strings. e.g. ``systemProperties = { visualvm.display.name = FooBar }`` + Keys and values of the map should be strings. e.g. ``systemProperties = { "visualvm.display.name" = FooBar }`` *Default:* not defined diff --git a/node/capsule/src/main/java/CordaCaplet.java b/node/capsule/src/main/java/CordaCaplet.java index b366b3aef9..00264b99fe 100644 --- a/node/capsule/src/main/java/CordaCaplet.java +++ b/node/capsule/src/main/java/CordaCaplet.java @@ -17,6 +17,7 @@ import java.util.jar.JarInputStream; import java.util.jar.Manifest; import java.util.stream.Stream; +import static com.typesafe.config.ConfigUtil.splitPath; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import static java.util.stream.Collectors.toMap; @@ -233,7 +234,6 @@ public class CordaCaplet extends Capsule { try { Map overrideSystemProps = nodeConfig.getConfig("systemProperties").entrySet().stream() .map(Property::create) - .filter(Property::isValid) .collect(toMap(Property::getKey, Property::getValue)); log(LOG_VERBOSE, "Configured system properties = " + overrideSystemProps); for (Map.Entry entry : overrideSystemProps.entrySet()) { @@ -321,20 +321,16 @@ public class CordaCaplet extends Capsule { * Helper class so that we can parse the "systemProperties" element of node.conf. */ private static class Property { - private final List path; + private final String key; private final Object value; - Property(List path, Object value) { - this.path = path; + Property(String key, Object value) { + this.key = key; this.value = value; } - boolean isValid() { - return path.size() == 1; - } - String getKey() { - return path.get(0); + return key; } Object getValue() { @@ -342,7 +338,12 @@ public class CordaCaplet extends Capsule { } static Property create(Map.Entry entry) { - return new Property(ConfigUtil.splitPath(entry.getKey()), entry.getValue().unwrapped()); + // String.join is preferred here over Typesafe's joinPath method, as the joinPath method would put quotes around the system + // property key which is undesirable here. + return new Property( + String.join(".", splitPath(entry.getKey())), + entry.getValue().unwrapped() + ); } } }