This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
     new 1e78a66a44 NIFI-12930 Catch FlowFileAccessException in FetchFile
1e78a66a44 is described below

commit 1e78a66a44135191c73ac726c5e424113d9fbfaa
Author: Joseph Witt <joew...@apache.org>
AuthorDate: Thu Mar 21 13:08:09 2024 -0700

    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 <exceptionfact...@apache.org>
    (cherry picked from commit d5ff51b6e4ee6907057b0838f627542f64b9f686)
---
 .../src/main/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 e16eec7189..f506a3891d 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
@@ -37,6 +37,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;
@@ -266,7 +267,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;

Reply via email to