diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java index c35ad8f7b6..3e39eadf2f 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/main/java/org/apache/nifi/processors/attributes/UpdateAttribute.java @@ -246,7 +246,6 @@ public class UpdateAttribute extends AbstractProcessor implements Searchable { .build(); } else { return propertyBuilder - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); } } diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/test/java/org/apache/nifi/update/attributes/TestUpdateAttribute.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/test/java/org/apache/nifi/update/attributes/TestUpdateAttribute.java index cd1a4fd68d..f2220100f6 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/test/java/org/apache/nifi/update/attributes/TestUpdateAttribute.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-processor/src/test/java/org/apache/nifi/update/attributes/TestUpdateAttribute.java @@ -107,6 +107,34 @@ public class TestUpdateAttribute { result.get(0).assertAttributeEquals("attribute.2", "new.value.2"); } + @Test + public void testSetEmptyString() throws Exception { + final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute()); + runner.setProperty("attribute.1", ""); + runner.assertValid(); + + // No attributes on flowfile + runner.enqueue(new byte[0]); + + runner.run(); + + runner.assertAllFlowFilesTransferred(UpdateAttribute.REL_SUCCESS, 1); + List result = runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS); + assertTrue(result.get(0).getAttribute("attribute.1").isEmpty()); + runner.clearTransferState(); + + final Map attributes = new HashMap<>(); + attributes.put("attribute.1", "old.value.1"); + // Existing attribute to be replaced on flowfile + runner.enqueue(new byte[0], attributes); + + runner.run(); + + runner.assertAllFlowFilesTransferred(UpdateAttribute.REL_SUCCESS, 1); + result = runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS); + assertTrue(result.get(0).getAttribute("attribute.1").isEmpty()); + } + @Test public void testDefaultAddAttribute() throws Exception { final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());