From d5ff51b6e4ee6907057b0838f627542f64b9f686 Mon Sep 17 00:00:00 2001 From: Joseph Witt Date: Thu, 21 Mar 2024 13:08:09 -0700 Subject: [PATCH] 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 --- .../java/org/apache/nifi/processors/standard/FetchFile.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java index 8e90fe9815..cdf03e0fa0 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/FetchFile.java @@ -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;