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

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new d5ff51b6e4 NIFI-12930 Catch FlowFileAccessException in FetchFile
d5ff51b6e4 is described below

commit d5ff51b6e4ee6907057b0838f627542f64b9f686
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>
---
 .../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 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;

Reply via email to