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

mthomsen 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 5493fde3c0 NIFI-13538 Do not include exception details in FlowFile 
attributes in DeleteFile
5493fde3c0 is described below

commit 5493fde3c041d03398ff1c8a50cec2cb6717499d
Author: EndzeitBegins <[email protected]>
AuthorDate: Wed Jul 10 22:23:55 2024 +0200

    NIFI-13538 Do not include exception details in FlowFile attributes in 
DeleteFile
    
    This closes #9070
    
    Signed-off-by: Mike Thomsen <[email protected]>
---
 .../nifi/processors/standard/DeleteFile.java       | 22 ----------------------
 .../nifi/processors/standard/TestDeleteFile.java   |  8 --------
 2 files changed, 30 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteFile.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteFile.java
index ae40269759..70050b3348 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteFile.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteFile.java
@@ -21,8 +21,6 @@ import org.apache.nifi.annotation.behavior.InputRequirement;
 import org.apache.nifi.annotation.behavior.Restricted;
 import org.apache.nifi.annotation.behavior.Restriction;
 import org.apache.nifi.annotation.behavior.SupportsBatching;
-import org.apache.nifi.annotation.behavior.WritesAttribute;
-import org.apache.nifi.annotation.behavior.WritesAttributes;
 import org.apache.nifi.annotation.documentation.CapabilityDescription;
 import org.apache.nifi.annotation.documentation.Tags;
 import org.apache.nifi.components.PropertyDescriptor;
@@ -53,17 +51,6 @@ import java.util.concurrent.TimeUnit;
 @InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
 @Tags({"file", "remove", "delete", "local", "files", "filesystem"})
 @CapabilityDescription("Deletes a file from the filesystem.")
-@WritesAttributes({
-        @WritesAttribute(
-                attribute = DeleteFile.ATTRIBUTE_FAILURE_REASON,
-                description = "Human-readable reason of failure. Only 
available if FlowFile is routed to relationship 'failure'."),
-        @WritesAttribute(
-                attribute = DeleteFile.ATTRIBUTE_EXCEPTION_CLASS,
-                description = "The class name of the exception thrown during 
processor execution. Only available if an exception caused the FlowFile to be 
routed to relationship 'failure'."),
-        @WritesAttribute(
-                attribute = DeleteFile.ATTRIBUTE_EXCEPTION_MESSAGE,
-                description = "The message of the exception thrown during 
processor execution. Only available if an exception caused the FlowFile to be 
routed to relationship 'failure'.")
-})
 @Restricted(
         restrictions = {
                 @Restriction(
@@ -76,10 +63,6 @@ import java.util.concurrent.TimeUnit;
 )
 public class DeleteFile extends AbstractProcessor {
 
-    public static final String ATTRIBUTE_FAILURE_REASON = 
"DeleteFile.failure.reason";
-    public static final String ATTRIBUTE_EXCEPTION_CLASS = 
"DeleteFile.failure.exception.class";
-    public static final String ATTRIBUTE_EXCEPTION_MESSAGE = 
"DeleteFile.failure.exception.message";
-
     public static final Relationship REL_SUCCESS = new Relationship.Builder()
             .name("success")
             .description("All FlowFiles, for which an existing file has been 
deleted, are routed to this relationship")
@@ -172,11 +155,6 @@ public class DeleteFile extends AbstractProcessor {
     private void handleFailure(ProcessSession session, FlowFile flowFile, 
String errorMessage, Throwable throwable) {
         getLogger().error(errorMessage, throwable);
 
-        session.putAttribute(flowFile, ATTRIBUTE_FAILURE_REASON, errorMessage);
-        if (throwable != null) {
-            session.putAttribute(flowFile, ATTRIBUTE_EXCEPTION_CLASS, 
throwable.getClass().toString());
-            session.putAttribute(flowFile, ATTRIBUTE_EXCEPTION_MESSAGE, 
throwable.getMessage());
-        }
         session.penalize(flowFile);
         session.transfer(flowFile, REL_FAILURE);
     }
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteFile.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteFile.java
index 91e44e4543..369628c3e2 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteFile.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteFile.java
@@ -116,10 +116,6 @@ class TestDeleteFile {
         assertExists(fileToDelete);
         runner.assertAllFlowFilesTransferred(DeleteFile.REL_FAILURE);
         runner.assertPenalizeCount(1);
-        final MockFlowFile resultFlowFile = 
runner.getFlowFilesForRelationship(DeleteFile.REL_FAILURE).get(0);
-        
resultFlowFile.assertAttributeExists(DeleteFile.ATTRIBUTE_FAILURE_REASON);
-        
resultFlowFile.assertAttributeExists(DeleteFile.ATTRIBUTE_EXCEPTION_CLASS);
-        
resultFlowFile.assertAttributeExists(DeleteFile.ATTRIBUTE_EXCEPTION_MESSAGE);
     }
 
     @Test
@@ -135,10 +131,6 @@ class TestDeleteFile {
         assertExists(fileToDelete);
         runner.assertAllFlowFilesTransferred(DeleteFile.REL_FAILURE, 1);
         runner.assertPenalizeCount(1);
-        final MockFlowFile resultFlowFile = 
runner.getFlowFilesForRelationship(DeleteFile.REL_FAILURE).get(0);
-        
resultFlowFile.assertAttributeExists(DeleteFile.ATTRIBUTE_FAILURE_REASON);
-        
resultFlowFile.assertAttributeNotExists(DeleteFile.ATTRIBUTE_EXCEPTION_CLASS);
-        
resultFlowFile.assertAttributeNotExists(DeleteFile.ATTRIBUTE_EXCEPTION_MESSAGE);
     }
 
     private MockFlowFile enqueue(String directoryPath, String filename) {

Reply via email to