You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/11/24 17:31:27 UTC

[GitHub] [nifi] turcsanyip commented on a change in pull request #5550: NIFI-9391: Modified MergeRecord to process FlowFiles within a loop in…

turcsanyip commented on a change in pull request #5550:
URL: https://github.com/apache/nifi/pull/5550#discussion_r756298420



##########
File path: nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java
##########
@@ -221,28 +221,18 @@ public void run(final int iterations, final boolean stopOnFinish, final boolean
             } catch (final InterruptedException e1) {
             }
 
-            int finishedCount = 0;
-            boolean unscheduledRun = false;
             for (final Future<Throwable> future : futures) {
                 try {
                     final Throwable thrown = future.get(); // wait for the result
                     if (thrown != null) {
                         throw new AssertionError(thrown);
                     }
-
-                    if (++finishedCount == 1) {
-                        unscheduledRun = true;
-                        unSchedule();
-                    }
                 } catch (final Exception e) {
                 }
             }
 
-            if (!unscheduledRun) {
-                unSchedule();
-            }
-
             if (stopOnFinish) {
+                unSchedule();

Review comment:
       @markap14 Thanks for your feedback and highlighting some aspects of how the test framework runs the processors and what the motivations are behind that. I totally agree that using `@OnUnscheduled` and `@OnStopped` in the proper way is a big issue that needs to be tested somehow. It was just weird for me (and broke my tests) that the second run of the processor happened in unscheduled state.
   My test case:
   - enqueue some FFs
   - run (trigger) the processor once
   - enqueue some more FFs
   - run (trigger) the processor one more
   
   I expected the processor to keep being scheduled between and during the 2 runs (as normally happens when I don't want to stop it).
   
   I tried your suggestion about using `if (++finishedCount == 1 && stopOnFinish) {`. It works if I also add stopOnFinish check to `if (!unscheduledRun && stopOnFinish) {` (line 241 in the original version).
   Actually, it falls back to my
   ```
               if (stopOnFinish) {
                   unSchedule();
                   stop();
               }
   ```
   solution if run(1) was called.
   
   Would that be fine with you?




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org