mirror of https://github.com/apache/nifi.git
NIFI-12930 Catch FlowFileAccessException in FetchFile
when importing a fetched file we cannot be sure if the problem is reading the source file or writing to the content repository. So we need to route to failure to allow flow designers to choose how to handle this. This closes #8542 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
69f1a3be4d
commit
d5ff51b6e4
|
@ -39,6 +39,7 @@ import org.apache.nifi.processor.AbstractProcessor;
|
|||
import org.apache.nifi.processor.ProcessContext;
|
||||
import org.apache.nifi.processor.ProcessSession;
|
||||
import org.apache.nifi.processor.Relationship;
|
||||
import org.apache.nifi.processor.exception.FlowFileAccessException;
|
||||
import org.apache.nifi.processor.exception.ProcessException;
|
||||
import org.apache.nifi.processor.util.StandardValidators;
|
||||
import org.apache.nifi.util.StopWatch;
|
||||
|
@ -312,7 +313,7 @@ public class FetchFile extends AbstractProcessor {
|
|||
// import content from file system
|
||||
try (final FileInputStream fis = new FileInputStream(file)) {
|
||||
flowFile = session.importFrom(fis, flowFile);
|
||||
} catch (final IOException ioe) {
|
||||
} catch (final IOException | FlowFileAccessException ioe) {
|
||||
getLogger().error("Could not fetch file {} from file system for {} due to {}; routing to failure", file, flowFile, ioe.toString(), ioe);
|
||||
session.transfer(session.penalize(flowFile), REL_FAILURE);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue