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/03/01 05:51:32 UTC

[GitHub] [nifi-minifi-cpp] adam-markovics commented on a change in pull request #1252: MINIFICPP-1686 - Processor destructors are not called

adam-markovics commented on a change in pull request #1252:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1252#discussion_r816467679



##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -697,10 +689,21 @@ PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo
     if (defaultType == typeid(int64_t)) {
       coercedValue = propertyValueNode.as<int64_t>();
     } else if (defaultType == typeid(uint64_t)) {
-      try {
-        coercedValue = propertyValueNode.as<uint64_t>();
-      } catch (...) {
-        coercedValue = propertyValueNode.as<std::string>();
+      const auto uValue = propertyValueNode.as<uint64_t>(0);
+
+      // parsing uint64_t may have failed
+      if (uValue == 0) {
+        const auto sValue = propertyValueNode.as<std::string>();
+
+        // parsing uint64_t did not fail, the node was a 0
+        if (sValue == "0") {
+          coercedValue = uValue;
+        } else {
+          // parsing uint64_t really failed
+          coercedValue = sValue;
+        }
+      } else {
+        coercedValue = uValue;

Review comment:
       This is a good alternative, thanks.

##########
File path: libminifi/src/core/yaml/YamlConfiguration.cpp
##########
@@ -697,10 +689,21 @@ PropertyValue YamlConfiguration::getValidatedProcessorPropertyForDefaultTypeInfo
     if (defaultType == typeid(int64_t)) {
       coercedValue = propertyValueNode.as<int64_t>();
     } else if (defaultType == typeid(uint64_t)) {
-      try {
-        coercedValue = propertyValueNode.as<uint64_t>();
-      } catch (...) {
-        coercedValue = propertyValueNode.as<std::string>();
+      const auto uValue = propertyValueNode.as<uint64_t>(0);
+
+      // parsing uint64_t may have failed
+      if (uValue == 0) {
+        const auto sValue = propertyValueNode.as<std::string>();
+
+        // parsing uint64_t did not fail, the node was a 0
+        if (sValue == "0") {
+          coercedValue = uValue;
+        } else {
+          // parsing uint64_t really failed
+          coercedValue = sValue;
+        }
+      } else {
+        coercedValue = uValue;

Review comment:
       This is a good alternative, thanks.




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