You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/09/09 14:10:49 UTC

[GitHub] [nifi-minifi-cpp] hunyadi-dev opened a new pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

hunyadi-dev opened a new pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901


   Splitting up YamlConfiguration::parsePropertiesNodeYaml and simplifying each of the parsing steps.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r497676730



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());

Review comment:
       this is old code, too, but I would remove the `.c_str()`'s here (and also elsewhere in the log lines), as they are not needed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r497663818



##########
File path: libminifi/include/core/yaml/YamlConfiguration.h
##########
@@ -260,6 +260,10 @@ class YamlConfiguration : public FlowConfiguration {
    */
   void parseProvenanceReportingYaml(YAML::Node *reportNode, core::ProcessGroup *parentGroup);
 
+  PropertyValue getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode);
+  void parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &yaml_section);
+  void parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor);
+  void parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &yaml_section);

Review comment:
       Can these be private?

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {

Review comment:
       I know it was like this before, but why is this not `const auto&`?

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+      }
+    }
+  } else {
+    logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+  }
+}
+
+void YamlConfiguration::parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  logger_->log_trace("Encountered %s", propertyName);
+  if (propertyValueNode.IsNull() || !propertyValueNode.IsDefined()) {
+    return;
+  }
+  if (propertyValueNode.IsSequence()) {
+    parsePropertyValueSequence(propertyName, propertyValueNode, processor, yaml_section);
+  } else {
+    parseSingleProperty(propertyName, propertyValueNode, processor);
+  }
+}
+
+void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
+    const std::string &yaml_section) {
+  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
+  logger_->log_trace("Entered %s", component_name);
+  for (const auto propertyElem : *propertiesNode) {

Review comment:
       ```suggestion
     for (const auto& propertyElem : *propertiesNode) {
   ```

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());

Review comment:
       this is old code, too, but I would remove the `.c_str()`'s here (and also in the other branch), as they are not needed

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {

Review comment:
       ```suggestion
       if (proc) {
   ```

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {

Review comment:
       ```suggestion
           if (proc) {
   ```

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);

Review comment:
       this could be `PropertyValue coercedValue = ...`

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.

Review comment:
       I would move this comment to before the `getValidatedProcessorPropertyForDefaultTypeInfo` function (either here, on in the header file).

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();

Review comment:
       Hm... this has changed quite a bit.  For example, why don't we need the case for `uint64_t` any longer?
   
   Also, do we have enough unit tests to make sure the new code works in the same way as the old code?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539409268



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {

Review comment:
       Yep, redundancies :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539407642



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());

Review comment:
       It was a warning before.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());

Review comment:
       It was a warning before.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r540772007



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.

Review comment:
       Updated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539420540



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+      }
+    }
+  } else {
+    logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+  }
+}
+
+void YamlConfiguration::parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  logger_->log_trace("Encountered %s", propertyName);
+  if (propertyValueNode.IsNull() || !propertyValueNode.IsDefined()) {
+    return;
+  }
+  if (propertyValueNode.IsSequence()) {
+    parsePropertyValueSequence(propertyName, propertyValueNode, processor, yaml_section);
+  } else {
+    parseSingleProperty(propertyName, propertyValueNode, processor);
+  }
+}
+
+void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
+    const std::string &yaml_section) {
+  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
+  logger_->log_trace("Entered %s", component_name);
+  for (const auto propertyElem : *propertiesNode) {

Review comment:
       In this case I'm fine with either.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r540823293



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();

Review comment:
       Honestly, I do not quite remember why we do not need `uint64_t` anymore :S
   
   It probably has something to do with the uint64 nodes being parsed as string even though their value type matches here:
   ```c++
   class DataSizeValue : public TransformableValue, public state::response::UInt64Value {
   ```
   
   There has been a discussion about it where @szaszm replied that he agreed on the removal, but gah this is old. This should be though thoroughly tested as there are many integration tests that directly rely on yamlparsing and even some yamlconfiguration tests as well.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539409634



##########
File path: libminifi/include/core/yaml/YamlConfiguration.h
##########
@@ -260,6 +260,10 @@ class YamlConfiguration : public FlowConfiguration {
    */
   void parseProvenanceReportingYaml(YAML::Node *reportNode, core::ProcessGroup *parentGroup);
 
+  PropertyValue getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode);
+  void parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &yaml_section);
+  void parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor);
+  void parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &yaml_section);

Review comment:
       Sure!




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539398222



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());

Review comment:
       I just recently realized that `std::string` was supported by the logger. Before that I was deliberately using `.c_str()` :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539407642



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());

Review comment:
       It was a warning before. I am not saying it is ought to be, but I would think this info is important and not to be hidden.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r542202475



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -770,106 +770,122 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
-          } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName, rawValueString);
           } else {
-            coercedValue = defaultValue;
-          }
-        }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName, rawValueString);
           }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
         }
       }
     }
   }
+}
+
+namespace {
+  void handleExceptionOnValidatedProcessorPropertyRead(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode,
+      const std::shared_ptr<Configure>& config, const std::type_index& defaultType, std::shared_ptr<logging::Logger>& logger) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (config->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      logger->log_error("Invalid conversion for %s to %s.", propertyFromProcessor.getName(), defaultType.name());
+    }
+  }
+}  // namespace
+
+// coerce the types. upon failure we will either exit or use the default value.
+// we do this here ( in addition to the PropertyValue class ) to get the earliest
+// possible YAML failure.
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  const std::type_index defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(uint64_t)) {
+      try {
+        coercedValue = propertyValueNode.as<uint64_t>();;

Review comment:
       Corrected.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539360257



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());

Review comment:
       Why is this a warning? It should be info or debug IMO.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {

Review comment:
       I think it would be worthwhile to catch and log `std::exception` compatible exception types.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());

Review comment:
       Same here, should be info or debug.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);

Review comment:
       or even better, `const PropertyValue coercedValue = ...`
   
   (this is a reply, scroll up if you don't see the context)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r540902387



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -770,106 +770,122 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
-          } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName, rawValueString);
           } else {
-            coercedValue = defaultValue;
-          }
-        }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName, rawValueString);
           }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
         }
       }
     }
   }
+}
+
+namespace {
+  void handleExceptionOnValidatedProcessorPropertyRead(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode,
+      const std::shared_ptr<Configure>& config, const std::type_index& defaultType, std::shared_ptr<logging::Logger>& logger) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (config->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      logger->log_error("Invalid conversion for %s to %s.", propertyFromProcessor.getName(), defaultType.name());
+    }
+  }
+}  // namespace
+
+// coerce the types. upon failure we will either exit or use the default value.
+// we do this here ( in addition to the PropertyValue class ) to get the earliest
+// possible YAML failure.
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  const std::type_index defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(uint64_t)) {
+      try {
+        coercedValue = propertyValueNode.as<uint64_t>();;

Review comment:
       minor, but there is an extra `;` at the end of the line




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm closed pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539397421



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {

Review comment:
       I think iterator value on a yaml node creates a custom type either way. This way this detail is not hidden:
   https://github.com/apache/nifi-minifi-cpp/blob/main/thirdparty/yaml-cpp-yaml-cpp-20171024/include/yaml-cpp/node/detail/node_iterator.h#L144




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539405836



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);
+
+  const std::string rawValueString = propertyValueNode.as<std::string>();
+  if (!processor->setProperty(myProp, coercedValue)) {
+    std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+    if (proc != 0) {
+      logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+      if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+        logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
+      } else {
+        logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+      }
+    }
+  } else {
+    logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
+  }
+}
+
+void YamlConfiguration::parsePropertyNodeElement(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  logger_->log_trace("Encountered %s", propertyName);
+  if (propertyValueNode.IsNull() || !propertyValueNode.IsDefined()) {
+    return;
+  }
+  if (propertyValueNode.IsSequence()) {
+    parsePropertyValueSequence(propertyName, propertyValueNode, processor, yaml_section);
+  } else {
+    parseSingleProperty(propertyName, propertyValueNode, processor);
+  }
+}
+
+void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
+    const std::string &yaml_section) {
+  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
+  logger_->log_trace("Entered %s", component_name);
+  for (const auto propertyElem : *propertiesNode) {

Review comment:
       I think iterator value on a yaml node creates a custom type either way. This way this detail is not hidden:
   https://github.com/apache/nifi-minifi-cpp/blob/main/thirdparty/yaml-cpp-yaml-cpp-20171024/include/yaml-cpp/node/detail/node_iterator.h#L144




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r540772139



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {
+    std::string eof;
+    bool exit_on_failure = false;
+    if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
+      utils::StringUtils::StringToBool(eof, exit_on_failure);
+    }
+    logger_->log_error("Invalid conversion for field %s. Value %s", propertyFromProcessor.getName(), propertyValueNode.as<std::string>());
+    if (exit_on_failure) {
+      // We do not exit here even if exit_on_failure is set. Maybe we should?
+      std::cerr << "Invalid conversion for " << propertyFromProcessor.getName() << " to " << defaultType.name() << std::endl;
+    }
+  }
+  return defaultValue;
+}
+
+void YamlConfiguration::parseSingleProperty(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor) {
+  core::Property myProp(propertyName, "", "");
+  processor->getProperty(propertyName, myProp);
+  PropertyValue coercedValue;
+
+  // coerce the types. upon failure we will either exit or use the default value.
+  // we do this here ( in addition to the PropertyValue class ) to get the earliest
+  // possible YAML failure.
+  coercedValue = getValidatedProcessorPropertyForDefaultTypeInfo(myProp, propertyValueNode);

Review comment:
       Updated




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r544313026



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();

Review comment:
       I don't remember the discussion, so some pointers to context would be appreciated. :slightly_smiling_face: 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi-minifi-cpp] hunyadi-dev commented on a change in pull request #901: MINIFICPP-1288 - Refactor YamlConfiguration::parsePropertiesNodeYaml

Posted by GitBox <gi...@apache.org>.
hunyadi-dev commented on a change in pull request #901:
URL: https://github.com/apache/nifi-minifi-cpp/pull/901#discussion_r539402194



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -762,106 +762,109 @@ void YamlConfiguration::parsePortYaml(YAML::Node *portNode, core::ProcessGroup *
   }
 }
 
-void YamlConfiguration::parsePropertiesNodeYaml(YAML::Node *propertiesNode, std::shared_ptr<core::ConfigurableComponent> processor, const std::string &component_name,
-                                                const std::string &yaml_section) {
-  // Treat generically as a YAML node so we can perform inspection on entries to ensure they are populated
-  logger_->log_trace("Entered %s", component_name);
-  for (YAML::const_iterator propsIter = propertiesNode->begin(); propsIter != propertiesNode->end(); ++propsIter) {
-    std::string propertyName = propsIter->first.as<std::string>();
-    YAML::Node propertyValueNode = propsIter->second;
-    logger_->log_trace("Encountered %s", propertyName);
-    if (!propertyValueNode.IsNull() && propertyValueNode.IsDefined()) {
-      if (propertyValueNode.IsSequence()) {
-        for (auto iter : propertyValueNode) {
-          if (iter.IsDefined()) {
-            YAML::Node nodeVal = iter.as<YAML::Node>();
-            YAML::Node propertiesNode = nodeVal["value"];
-            // must insert the sequence in differently.
-            std::string rawValueString = propertiesNode.as<std::string>();
-            logger_->log_debug("Found %s=%s", propertyName, rawValueString);
-            if (!processor->updateProperty(propertyName, rawValueString)) {
-              std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-              if (proc != 0) {
-                logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                                  "Attempting to add as dynamic property.",
-                                  propertyName, rawValueString, proc->getName());
-                if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-                  logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-                } else {
-                  logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-                }
-              }
-            }
-          }
-        }
-      } else {
-        core::Property myProp(propertyName, "", "");
-        processor->getProperty(propertyName, myProp);
-        PropertyValue defaultValue;
-        defaultValue = myProp.getDefaultValue();
-        auto defaultType = defaultValue.getTypeInfo();
-        PropertyValue coercedValue = defaultValue;
-
-        // coerce the types. upon failure we will either exit or use the default value.
-        // we do this here ( in addition to the PropertyValue class ) to get the earliest
-        // possible YAML failure.
-        try {
-          if (defaultType == typeid(std::string)) {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(int64_t)) {
-            auto typedValue = propertyValueNode.as<int64_t>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(uint64_t)) {
-            try {
-              auto typedValue = propertyValueNode.as<uint64_t>();
-              coercedValue = typedValue;
-            } catch (...) {
-              auto typedValue = propertyValueNode.as<std::string>();
-              coercedValue = typedValue;
-            }
-          } else if (defaultType == typeid(int)) {
-            auto typedValue = propertyValueNode.as<int>();
-            coercedValue = typedValue;
-          } else if (defaultType == typeid(bool)) {
-            auto typedValue = propertyValueNode.as<bool>();
-            coercedValue = typedValue;
+void YamlConfiguration::parsePropertyValueSequence(const std::string& propertyName, const YAML::Node& propertyValueNode, std::shared_ptr<core::ConfigurableComponent> processor,
+    const std::string &yaml_section) {
+  for (auto iter : propertyValueNode) {
+    if (iter.IsDefined()) {
+      YAML::Node nodeVal = iter.as<YAML::Node>();
+      YAML::Node propertiesNode = nodeVal["value"];
+      // must insert the sequence in differently.
+      std::string rawValueString = propertiesNode.as<std::string>();
+      logger_->log_debug("Found %s=%s", propertyName, rawValueString);
+      if (!processor->updateProperty(propertyName, rawValueString)) {
+        std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
+        if (proc != 0) {
+          logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. Attempting to add as dynamic property.", propertyName, rawValueString, proc->getName());
+          if (!processor->setDynamicProperty(propertyName, rawValueString)) {
+            logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
           } else {
-            auto typedValue = propertyValueNode.as<std::string>();
-            coercedValue = typedValue;
-          }
-        } catch (...) {
-          std::string eof;
-          bool exit_on_failure = false;
-          if (configuration_->get(Configure::nifi_flow_configuration_file_exit_failure, eof)) {
-            utils::StringUtils::StringToBool(eof, exit_on_failure);
-          }
-          logger_->log_error("Invalid conversion for field %s. Value %s", myProp.getName(), propertyValueNode.as<std::string>());
-          if (exit_on_failure) {
-            std::cerr << "Invalid conversion for " << myProp.getName() << " to " << defaultType.name() << std::endl;
-          } else {
-            coercedValue = defaultValue;
+            logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
           }
         }
-        std::string rawValueString = propertyValueNode.as<std::string>();
-        if (!processor->setProperty(myProp, coercedValue)) {
-          std::shared_ptr<core::Connectable> proc = std::dynamic_pointer_cast<core::Connectable>(processor);
-          if (proc != 0) {
-            logger_->log_warn("Received property %s with value %s but is not one of the properties for %s. "
-                              "Attempting to add as dynamic property.",
-                              propertyName, rawValueString, proc->getName());
-            if (!processor->setDynamicProperty(propertyName, rawValueString)) {
-              logger_->log_warn("Unable to set the dynamic property %s with value %s", propertyName.c_str(), rawValueString.c_str());
-            } else {
-              logger_->log_warn("Dynamic property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-            }
-          }
-        } else {
-          logger_->log_debug("Property %s with value %s set", propertyName.c_str(), rawValueString.c_str());
-        }
       }
     }
   }
+}
+
+PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo(const core::Property& propertyFromProcessor, const YAML::Node& propertyValueNode) {
+  PropertyValue defaultValue;
+  defaultValue = propertyFromProcessor.getDefaultValue();
+  auto defaultType = defaultValue.getTypeInfo();
+  try {
+    PropertyValue coercedValue = defaultValue;
+    if (defaultType == typeid(int64_t)) {
+      coercedValue = propertyValueNode.as<int64_t>();
+    } else if (defaultType == typeid(int)) {
+      coercedValue = propertyValueNode.as<int>();
+    } else if (defaultType == typeid(bool)) {
+      coercedValue = propertyValueNode.as<bool>();
+    } else {
+      coercedValue = propertyValueNode.as<std::string>();
+    }
+    return coercedValue;
+  } catch (...) {

Review comment:
       Will add logging.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org