Kaynağa Gözat

HPCC-23464 Fix incorrect test in new loadConfigration code

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 5 yıl önce
ebeveyn
işleme
b12199504f
1 değiştirilmiş dosya ile 10 ekleme ve 4 silme
  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;