Created 04-20-2017 08:49 PM
Does any one know why or under what circumstances NIFI passes a null flowfile to a custom NIFI processor ? We are seeing cases where the session that is passed in as an input to the onTrigger method of the custom (java) processor contains a session with a null flow file. Is this a normal condition ? We are treating it as an error case and logging it as an error. (Not sure if this is the correct thing to do.
The following code inside of the custom processor's "onTrigger" method is returning a null flow file.
FlowFile flowFile = session.get();
if (flowFile == null) {
getLogger().error("End Invocation - Failure " + className + "Instance HashCode: " + hashCode + " onTrigger operation. Got null flowflile from session " + sessionHashCode +" and returning control to NIFI at " + System.currentTimeMillis()); return;
}
Created 04-20-2017 09:16 PM
This is normal behavior, typically you just call session.get() and if the flow file returned is null then just return from the processor:
The most common reason for this is when concurrent tasks is set to more than 1 for a processor with an input queue. In this case, the framework might trigger both threads to execute, but thread 1 might grab the only flow file, or all the available flow files, and by the time thread 2 executes there is nothing left.
Created 04-20-2017 09:16 PM
This is normal behavior, typically you just call session.get() and if the flow file returned is null then just return from the processor:
The most common reason for this is when concurrent tasks is set to more than 1 for a processor with an input queue. In this case, the framework might trigger both threads to execute, but thread 1 might grab the only flow file, or all the available flow files, and by the time thread 2 executes there is nothing left.
Created 03-20-2018 01:29 PM
I got the same "issue" and that is exactly the case for multiple threads.
Thanks,
Mark
Created 03-20-2018 01:40 PM
It's Java, if you aren't expecting nulls. Expect crashes.
First Rule of Java, Handle Nulls.
Second Rule of Java, Handle Exceptions because you forgot 1st rule.