lordgamez commented on code in PR #1990:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1990#discussion_r2254103403


##########
extensions/mqtt/processors/ConsumeMQTT.cpp:
##########
@@ -26,17 +25,44 @@
 #include "core/ProcessContext.h"
 #include "core/ProcessSession.h"
 #include "core/Resource.h"
+#include "io/BufferStream.h"
+#include "utils/ProcessorConfigUtils.h"
 #include "utils/StringUtils.h"
 #include "utils/ValueParser.h"
-#include "utils/ProcessorConfigUtils.h"
 
 namespace org::apache::nifi::minifi::processors {
+namespace {
+template<typename RecordSetIO>
+std::shared_ptr<RecordSetIO> getRecordSetIO(core::ProcessContext& context, 
const core::PropertyReference& property,
+    const utils::Identifier& processor_uuid) {
+  std::string service_name = context.getProperty(property).value_or("");
+  if (!IsNullOrEmpty(service_name)) {
+    auto record_set_io = 
std::dynamic_pointer_cast<RecordSetIO>(context.getControllerService(service_name,
 processor_uuid));
+    if (!record_set_io) {
+      throw Exception(ExceptionType::PROCESS_SCHEDULE_EXCEPTION, 
fmt::format("'{}' property is set to invalid controller service '{}'", 
property.name, service_name));
+    }
+    return record_set_io;
+  }
+  return nullptr;
+}

Review Comment:
   My problem with that currently that we do not differentiate if the property 
was set, but it was invalid or if the property was not set at all. Maybe we 
should change the current utility to only return std::nullopt if the input is 
invalid, otherwise return nullptr, what do you think?



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to