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 2022/04/27 09:22:05 UTC

[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1316: MINIFICPP-1687 Signal error on UUID collision

fgerlits commented on code in PR #1316:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1316#discussion_r859555580


##########
libminifi/include/core/yaml/YamlConfiguration.h:
##########
@@ -277,6 +278,7 @@ class YamlConfiguration : public FlowConfiguration {
    * @return         the parsed or generated UUID string
    */
   std::string getOrGenerateId(const YAML::Node& yamlNode, const std::string& idField = "id");
+  std::string getRequiredIdField(const YAML::Node& yaml_node, std::string_view yaml_section = "", std::string error_message = "");

Review Comment:
   could the type of `error_message` be `const std::string&`, to avoid copying?



##########
libminifi/src/core/yaml/YamlConfiguration.cpp:
##########
@@ -908,6 +914,14 @@ YAML::Node YamlConfiguration::getOptionalField(const YAML::Node& yamlNode, const
   return result;
 }
 
+void YamlConfiguration::addNewId(const std::string& uuid) {
+  if (uuids_.find(uuid) != uuids_.end()) {
+    throw Exception(ExceptionType::GENERAL_EXCEPTION, "UUID " + uuid + " is duplicated in the flow configuration");
+  }
+
+  uuids_.insert(uuid);

Review Comment:
   minor, but `insert()` returns whether the insertion was successful, so we could avoid doing two lookups:
   ```suggestion
     const auto [_, success] = uuids_.insert(uuid);
     if (!success) {
       throw Exception(ExceptionType::GENERAL_EXCEPTION, "UUID " + uuid + " is duplicated in the flow configuration");
     }
   ```



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

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