adamdebreceni commented on a change in pull request #797:
URL: https://github.com/apache/nifi-minifi-cpp/pull/797#discussion_r432817914



##########
File path: libminifi/include/core/ConfigurableComponent.h
##########
@@ -216,16 +216,20 @@ bool ConfigurableComponent::getProperty(const std::string 
name, T &value) const{
 
    auto &&it = properties_.find(name);
    if (it != properties_.end()) {
-     Property item = it->second;
-     value = static_cast<T>(item.getValue());
-     if (item.getValue().getValue() != nullptr){
-       logger_->log_debug("Component %s property name %s value %s", name, 
item.getName(), item.getValue().to_string());
-       return true;
-     }
-     else{
+     const Property& item = it->second;
+     if (item.getValue().getValue() == nullptr) {
+       // empty value
+       if (item.getRequired()) {
+         logger_->log_debug("Component %s required property %s is empty", 
name, item.getName());
+         throw utils::RequiredPropertyMissingException("Required property is 
empty: " + item.getName());

Review comment:
       the thing is, that you as a processor implementer should not care if 
`getProperty` throws or not, returning `false` means: "hey some error occurred 
that you should handle", throwing an exception means that somebody upstream 
messed up, e.g. called `onSchedule` without validating if all required 
properties are present or not checking invalid properties, if I mark a property 
required or add a validator I do not want to be have to handle if it is missing 
or invalid




----------------------------------------------------------------
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:
[email protected]


Reply via email to