fgerlits commented on code in PR #1990:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1990#discussion_r2254146463
##########
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:
Good point. Another option would be to throw on invalid and return either
nullopt or nullptr if the property is not set.
EDIT: we agreed that I will change `utils::parseOptionalControllerService()`
to throw (and also to not use `optional`) in a separate PR. For now, this can
stay as it is, and we will rebase one or the other PR depending on which gets
merged first.
--
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]