From 90d39831a0b68454e9a9c11d215315a714222e98 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Fri, 2 May 2014 10:31:57 -0400 Subject: [PATCH] Shrink previous patch to skip non-string Properties There was some extra/leftover logic in there. With this commit the diff vs. the original codebase is smaller and clearer. --- .../config/impl/PropertiesParser.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/config/src/main/java/com/typesafe/config/impl/PropertiesParser.java b/config/src/main/java/com/typesafe/config/impl/PropertiesParser.java index 12b57171..43ba2592 100644 --- a/config/src/main/java/com/typesafe/config/impl/PropertiesParser.java +++ b/config/src/main/java/com/typesafe/config/impl/PropertiesParser.java @@ -134,22 +134,26 @@ final class PropertiesParser { /* Store string values in the associated scope maps */ for (Path path : valuePaths) { - Object rawValue = pathMap.get(path); - if(!convertedFromProperties || rawValue instanceof String || rawValue instanceof Number || rawValue==null) { - Path parentPath = path.parent(); - Map parent = parentPath != null ? scopes - .get(parentPath) : root; + Path parentPath = path.parent(); + Map parent = parentPath != null ? scopes + .get(parentPath) : root; - String last = path.last(); - AbstractConfigValue value; - if (convertedFromProperties) { - value = new ConfigString(origin, rawValue.toString()); + String last = path.last(); + Object rawValue = pathMap.get(path); + AbstractConfigValue value; + if (convertedFromProperties) { + if (rawValue instanceof String) { + value = new ConfigString(origin, (String) rawValue); } else { - value = ConfigImpl.fromAnyRef(pathMap.get(path), origin, - FromMapMode.KEYS_ARE_PATHS); + // silently ignore non-string values in Properties + value = null; } - parent.put(last, value); + } else { + value = ConfigImpl.fromAnyRef(pathMap.get(path), origin, + FromMapMode.KEYS_ARE_PATHS); } + if (value != null) + parent.put(last, value); } /*