From d32a32a92d29707d22899862594a2679d3fb2273 Mon Sep 17 00:00:00 2001 From: Yu ISHIKAWA Date: Mon, 7 Sep 2015 23:32:48 +0900 Subject: [PATCH] Remove the process to check if the target key exists or not --- .../nifi/processors/aws/s3/DeleteS3Object.java | 15 --------------- .../processors/aws/s3/TestDeleteS3Object.java | 14 ++------------ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/DeleteS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/DeleteS3Object.java index dffcab8b58..c8950c3208 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/DeleteS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/DeleteS3Object.java @@ -64,11 +64,6 @@ public class DeleteS3Object extends AbstractS3Processor { public static final Set relationships = Collections.unmodifiableSet( new HashSet<>(Arrays.asList(REL_SUCCESS, REL_FAILURE, REL_NOT_FOUND))); - @Override - public Set getRelationships() { - return relationships; - } - @Override protected List getSupportedPropertyDescriptors() { return properties; @@ -89,16 +84,6 @@ public class DeleteS3Object extends AbstractS3Processor { final AmazonS3 s3 = getClient(); - // Checks if the key exists or not - // If there is no such a key, then throws a exception - try { - s3.getObjectMetadata(bucket, key); - } catch (final AmazonServiceException ase) { - getLogger().error("Not found such a S3 object for {}; routing to not found", new Object[]{flowFile, ase}); - session.transfer(flowFile, REL_NOT_FOUND); - return; - } - // Deletes a key on Amazon S3 try { if (versionId == null) { diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java index 04d9e61e32..082a80d850 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestDeleteS3Object.java @@ -22,12 +22,9 @@ import java.io.IOException; import java.net.URL; import java.util.HashMap; import java.util.Map; -import java.util.Set; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.assertEquals; import com.amazonaws.auth.PropertiesCredentials; import com.amazonaws.services.s3.AmazonS3Client; @@ -36,7 +33,7 @@ import com.amazonaws.services.s3.model.CreateBucketRequest; import com.amazonaws.services.s3.model.DeleteBucketRequest; import com.amazonaws.services.s3.model.PutObjectRequest; import com.amazonaws.services.s3.model.PutObjectResult; -import org.apache.nifi.processor.Relationship; + import org.apache.nifi.util.TestRunner; import org.apache.nifi.util.TestRunners; @@ -128,14 +125,7 @@ public class TestDeleteS3Object { runner.enqueue(new byte[0], attrs); runner.run(1); - runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_NOT_FOUND, 1); - } - - @Test - public void testGetRelationships() { - DeleteS3Object deleter = new DeleteS3Object(); - Set relationships = deleter.getRelationships(); - assertEquals(relationships.size(), 3); + runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_FAILURE, 1); } // Uploads a test file