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


##########
libminifi/test/libtest/unit/StatefulProcessor.cpp:
##########
@@ -21,23 +21,27 @@
 #include "minifi-cpp/Exception.h"
 #include "core/Resource.h"
 #include "minifi-cpp/core/ProcessContext.h"
+#include "core/ProcessSession.h"
 
 namespace org::apache::nifi::minifi::processors {
 
 void StatefulProcessor::onSchedule(core::ProcessContext& context, 
core::ProcessSessionFactory&) {
   std::lock_guard<std::mutex> lock(mutex_);
-  state_manager_ = context.getStateManager();
-  if (state_manager_ == nullptr) {
+  auto temp_state_manager = context.createStateManager();
+  if (temp_state_manager == nullptr) {
     throw Exception(PROCESSOR_EXCEPTION, "Failed to get StateManager");
   }
+  state_manager_ = temp_state_manager.get();
 
   if (on_schedule_hook_) {
     on_schedule_hook_(*state_manager_);
   }
+  state_manager_ = nullptr;
 }
 
-void StatefulProcessor::onTrigger(core::ProcessContext&, 
core::ProcessSession&) {
+void StatefulProcessor::onTrigger(core::ProcessContext& context, 
core::ProcessSession&) {
   std::lock_guard<std::mutex> lock(mutex_);
+  state_manager_ = context.getStateManager();

Review Comment:
   Updated in 
https://github.com/apache/nifi-minifi-cpp/pull/2157/commits/f9e15ed69137805a7acf6fe23fdb3adbc4ba90a7



##########
extensions/grafana-loki/PushGrafanaLoki.h:
##########
@@ -127,7 +127,7 @@ class PushGrafanaLoki : public core::ProcessorImpl {
     std::optional<std::chrono::milliseconds> log_line_batch_wait_;
     std::chrono::system_clock::time_point start_push_time_;
     std::vector<std::shared_ptr<core::FlowFile>> batched_flowfiles_;
-    core::StateManager* state_manager_;
+    core::StateManager* state_manager_ = nullptr;

Review Comment:
   This is only used as part of the LogBatch object, but I added a gsl::finally 
directive to clear it at the end of the onTrigger to be sure in 
https://github.com/apache/nifi-minifi-cpp/pull/2157/commits/f9e15ed69137805a7acf6fe23fdb3adbc4ba90a7



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