Copilot commented on code in PR #1983:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1983#discussion_r2162074296
##########
extensions/expression-language/ProcessContextExpr.cpp:
##########
@@ -70,13 +70,17 @@ nonstd::expected<void, std::error_code>
ProcessContextExpr::setDynamicProperty(s
std::map<std::string, std::string>
ProcessContextExpr::getDynamicProperties(const FlowFile* flow_file) const {
auto dynamic_props = ProcessContextImpl::getDynamicProperties(flow_file);
- for (auto& [dynamic_property_name, dynamic_property_value] : dynamic_props) {
- if (!cached_dynamic_expressions_.contains(dynamic_property_name)) {
+ const expression::Parameters params{this, flow_file};
+ for (auto& [dynamic_property_name, dynamic_property_value]: dynamic_props) {
+ auto cached_dyn_expr_it =
cached_dynamic_expressions_.find(dynamic_property_name);
+ if (cached_dyn_expr_it == cached_dynamic_expressions_.end()) {
auto expression = expression::compile(dynamic_property_value);
- expression::Parameters p(this, flow_file);
- dynamic_property_value = expression(p).asString();
- cached_dynamic_expressions_.emplace(std::string{dynamic_property_name},
std::move(expression));
+ const auto [it, success] =
cached_dynamic_expressions_.emplace(dynamic_property_name, expression);
+ gsl_Assert(success && "getDynamicProperties: no element with the key
existed, yet insertion failed");
Review Comment:
Using `gsl_Assert` for error handling can be disabled in release builds;
consider adding explicit error handling or logging to handle insertion failure
in production rather than relying solely on assertions.
--
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]