Browse Source

Merge pull request #13317 from ghalliday/issue23464b

HPCC-23464 Fix incorrect test in new loadConfigration code

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 years ago
parent
commit
fa11e67788
1 changed files with 10 additions and 4 deletions
  1. 10 4
      system/jlib/jptree.cpp

+ 10 - 4
system/jlib/jptree.cpp

@@ -7867,10 +7867,16 @@ static void displayConfig(IPropertyTree * config, const char * componentTag)
 
 jlib_decl IPropertyTree * loadConfiguration(const char * defaultYaml, const char * * argv, const char * componentTag, const char * envPrefix, const char * legacyFilename, IPropertyTree * (mapper)(IPropertyTree *))
 {
-    Owned<IPropertyTree> defaultConfig = createPTreeFromYAML(defaultYaml);
-    IPropertyTree * componentDefault = defaultConfig->queryPropTree(componentTag);
-    if (!componentTag)
-        throw makeStringExceptionV(99, "Default configuration does not contain the tag %s", componentTag);
+    Owned<IPropertyTree> componentDefault;
+    if (defaultYaml)
+    {
+        Owned<IPropertyTree> defaultConfig = createPTreeFromYAML(defaultYaml);
+        componentDefault.set(defaultConfig->queryPropTree(componentTag));
+        if (!componentDefault)
+            throw makeStringExceptionV(99, "Default configuration does not contain the tag %s", componentTag);
+    }
+    else
+        componentDefault.setown(createPTree(componentTag));
 
     Owned<IPropertyTree> config(mapJsonToXmlConfig(componentDefault));
     const char * optConfig = nullptr;