jrsteinebrey commented on code in PR #8951:
URL: https://github.com/apache/nifi/pull/8951#discussion_r1636418649


##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/groups/StandardDataValve.java:
##########
@@ -67,30 +70,46 @@ public synchronized boolean tryOpenFlowIntoGroup(final 
ProcessGroup destinationG
             return true;
         }
 
-        final String reasonForNotAllowing = 
getReasonFlowIntoGroupNotAllowed(destinationGroup);
+        final FlowInForbiddenReason reasonForNotAllowing = 
getReasonFlowIntoGroupNotAllowed(destinationGroup);
+
+        // If we are forbidding data to flow into the group due to the fact 
that data is currently allowed to flow out of the group,
+        // and the valve was left open due to data being queued, let's verify 
that there is actually data queued up to flow out at the moment.
+        // If there is not, remove the group from those that are currently 
allowing data to flow out. This can happen in the following situation:
+        // - A FlowFile comes into the group
+        // - The FlowFile is split into two FlowFiles
+        // - One of the FlowFiles is routed to the Output Port, while the 
other is routed elsewhere
+        // - The Output Port is triggered. It opens the valve to allow data to 
flow out of the group.
+        // - The Output Port goes to close flow out of the group. However, the 
group is not empty, so the valve is not closed.
+        // - The other FlowFile is never routed to an output port. Instead, it 
is auto-terminated by some processor.
+        // Now, the valve has been left open.
+        // In this case, though, when the Output Port failed to close the 
valve, this.leftOpenDueToDataQueued was set to true. If that is the case,
+        // we can go ahead and close the valve now, if there's no more data 
queued.
+        if (reasonForNotAllowing == FlowInForbiddenReason.OPEN_FOR_OUTPUT && 
leftOpenDueToDataQueued && !destinationGroup.isDataQueued()) {
+            groupsWithDataFlowingOut.remove(destinationGroup.getIdentifier());

Review Comment:
   I withdraw my above comment because I now that the code will work correctly 
as is because this tryOpenFlowIntoGroup will get called again in the future and 
then on the second call, it will open the flow.



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