Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2634#discussion_r181951840
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/tasks/ConnectableTask.java
---
@@ -103,8 +104,24 @@ private boolean isYielded() {
return connectable.getYieldExpiration() >
System.currentTimeMillis();
}
+ /**
+ * Make sure processor has work to do. This means that it meets one of
these criteria:
+ * <ol>
+ * <li>It is annotated with @TriggerWhenEmpty</li>
+ * <li>It has no incoming connections</li>
+ * <li>All incoming connections are self-loops</li>
+ * <li>It has data in an incoming Connection
+ * AND It is not a Funnel without outgoing connections
+ * </li>
+ * </ol>
+ * @return true if there is work to do, otherwise false
+ */
private boolean isWorkToDo() {
- return connectable.isTriggerWhenEmpty() ||
!connectable.hasIncomingConnection() || !hasNonLoopConnection ||
Connectables.flowFilesQueued(connectable);
+ return connectable.isTriggerWhenEmpty()
+ || !connectable.hasIncomingConnection()
+ || !hasNonLoopConnection
+ || (Connectables.flowFilesQueued(connectable)
--- End diff --
@markap14 Thank you for testing.
I understand what went wrong. I tested with an existing flow including
Funnel which had an incoming connection from GenerateFlowFile already. Since
Funnels are not stopped/scheduled, the `hasNonLoopConnection` field only gets
populated when the Funnel is added.
`hasNonLoopConnection` becomes `false` for a newly created Funnels, and
stays false even incoming connections are added later. ConnectableTasks for
other components than Funnel can be recreated when the component is
re-scheduled, however, those components should also NOT cache
`hasNonLoopConnection` because NiFi allows new connections to be added while a
component is running, without requiring stop/start.
I will update the PR.
---