From 59d258c6db00abe02f3d40b8715c202b3f7243af Mon Sep 17 00:00:00 2001 From: EndzeitBegins <16666115+EndzeitBegins@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:51:04 +0200 Subject: [PATCH] NIFI-13372 Do not write exception details in FlowFile attributes --- .../nifi/processors/standard/DeleteSFTP.java | 20 ------------------- .../processors/standard/TestDeleteSFTP.java | 8 -------- 2 files changed, 28 deletions(-) diff --git a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteSFTP.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteSFTP.java index e2520a3aad89f..e77b5e41f505d 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteSFTP.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/DeleteSFTP.java @@ -65,23 +65,8 @@ Using 'DeleteSFTP', delete the file residing on an SFTP server only after the result has been stored. """ ) -@WritesAttributes({ - @WritesAttribute( - attribute = DeleteSFTP.ATTRIBUTE_FAILURE_REASON, - description = "Human-readable reason of failure. Only available if FlowFile is routed to relationship 'failure'."), - @WritesAttribute( - attribute = DeleteSFTP.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 = DeleteSFTP.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'.") -}) public class DeleteSFTP extends AbstractProcessor { - public static final String ATTRIBUTE_FAILURE_REASON = "DeleteSFTP.failure.reason"; - public static final String ATTRIBUTE_EXCEPTION_CLASS = "DeleteSFTP.failure.exception.class"; - public static final String ATTRIBUTE_EXCEPTION_MESSAGE = "DeleteSFTP.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") @@ -232,11 +217,6 @@ protected Collection customValidate(ValidationContext validati 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-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteSFTP.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteSFTP.java index 8bc9bf18ed399..c6596feab0c6c 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteSFTP.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestDeleteSFTP.java @@ -119,10 +119,6 @@ void sendsFlowFileToFailureWhenTargetIsADirectory() throws IOException { assertExists(fileToDelete); runner.assertAllFlowFilesTransferred(DeleteSFTP.REL_FAILURE); runner.assertPenalizeCount(1); - final MockFlowFile resultFlowFile = runner.getFlowFilesForRelationship(DeleteSFTP.REL_FAILURE).getFirst(); - resultFlowFile.assertAttributeExists(DeleteSFTP.ATTRIBUTE_FAILURE_REASON); - resultFlowFile.assertAttributeExists(DeleteSFTP.ATTRIBUTE_EXCEPTION_CLASS); - resultFlowFile.assertAttributeExists(DeleteSFTP.ATTRIBUTE_EXCEPTION_MESSAGE); } @Test @@ -138,10 +134,6 @@ void sendsFlowFileToFailureWhenFileIsNotADirectChildOfTheDirectory() throws IOEx assertExists(fileToDelete); runner.assertAllFlowFilesTransferred(DeleteSFTP.REL_FAILURE, 1); runner.assertPenalizeCount(1); - final MockFlowFile resultFlowFile = runner.getFlowFilesForRelationship(DeleteSFTP.REL_FAILURE).getFirst(); - resultFlowFile.assertAttributeExists(DeleteSFTP.ATTRIBUTE_FAILURE_REASON); - resultFlowFile.assertAttributeNotExists(DeleteSFTP.ATTRIBUTE_EXCEPTION_CLASS); - resultFlowFile.assertAttributeNotExists(DeleteSFTP.ATTRIBUTE_EXCEPTION_MESSAGE); } @Test