mattyb149 commented on a change in pull request #3315: NIFI-5916 Added an 
option to enable empty flowfiles to be sent if the…
URL: https://github.com/apache/nifi/pull/3315#discussion_r262095588
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
 ##########
 @@ -228,12 +249,19 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
                     outgoingFlowFile = 
session.putAllAttributes(outgoingFlowFile, attributes);
                     session.getProvenanceReporter().receive(outgoingFlowFile, 
getURI(context));
                     session.transfer(outgoingFlowFile, REL_SUCCESS);
+                    sent++;
                 }
             }
 
             if (input != null) {
                 session.transfer(input, REL_ORIGINAL);
             }
+
+            if (sent == 0 && sendEmpty) {
+                FlowFile empty = session.create(input);
 
 Review comment:
   Still tracking down whether there's a bug or intended behavior, but if 
`input == null` here it causes an NPE (looks like its due to changes in #2974 
). Just to be safe it should probably check for null here and just call 
`create()` instead. Would make a good unit test too (to show it works without 
an incoming flow file).

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to