NIFI-1153: If no incoming FlowFile, don't try to transfer null

Reviewed by Bryan Bende (bbende@apache.org)
Amended based on review (change to a log message) by Tony Kurc (tkurc@apache.org)
This commit is contained in:
Mark Payne 2015-11-12 22:41:57 -05:00 committed by Tony Kurc
parent 33ef59c5ba
commit 0900fb80c9
1 changed files with 6 additions and 2 deletions

View File

@ -168,8 +168,12 @@ public class ExecuteSQL extends AbstractProcessor {
session.getProvenanceReporter().modifyContent(outgoing, "Retrieved " + nrOfRows.get() + " rows", stopWatch.getElapsed(TimeUnit.MILLISECONDS)); session.getProvenanceReporter().modifyContent(outgoing, "Retrieved " + nrOfRows.get() + " rows", stopWatch.getElapsed(TimeUnit.MILLISECONDS));
session.transfer(outgoing, REL_SUCCESS); session.transfer(outgoing, REL_SUCCESS);
} catch (final ProcessException | SQLException e) { } catch (final ProcessException | SQLException e) {
logger.error("Unable to execute SQL select query {} for {} due to {}; routing to failure", new Object[] { selectQuery, incoming, e }); if (incoming == null) {
logger.error("Unable to execute SQL select query {} due to {}. No incoming flow file to route to failure", new Object[] {selectQuery, e});
} else {
logger.error("Unable to execute SQL select query {} for {} due to {}; routing to failure", new Object[] {selectQuery, incoming, e});
session.transfer(incoming, REL_FAILURE); session.transfer(incoming, REL_FAILURE);
} }
} }
}
} }