You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2023/01/25 16:44:16 UTC
[nifi] branch main updated: NIFI-10853 Allow UpdateAttribute dynamic property to validate nifi expressions
This is an automated email from the ASF dual-hosted git repository.
mattyb149 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 b7f7b411ef NIFI-10853 Allow UpdateAttribute dynamic property to validate nifi expressions
b7f7b411ef is described below
commit b7f7b411efca794d91892f0b1b06a143e024a2a6
Author: Nissim Shiman <ns...@yahoo.com>
AuthorDate: Wed Dec 7 20:32:06 2022 +0000
NIFI-10853 Allow UpdateAttribute dynamic property to validate nifi
expressions
Signed-off-by: Matthew Burgess <ma...@apache.org>
This closes #6770
---
.../nifi/processors/attributes/UpdateAttribute.java | 15 ++++-----------
.../nifi/update/attributes/TestUpdateAttribute.java | 7 +++++++
2 files changed, 11 insertions(+), 11 deletions(-)
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 3e39eadf2f..cea1b47412 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
@@ -233,21 +233,14 @@ public class UpdateAttribute extends AbstractProcessor implements Searchable {
@Override
protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) {
- PropertyDescriptor.Builder propertyBuilder = new PropertyDescriptor.Builder()
+ return new PropertyDescriptor.Builder()
.name(propertyDescriptorName)
.required(false)
+ .addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
- .dynamic(true);
-
- if (stateful) {
- return propertyBuilder
- .addValidator(StandardValidators.createAttributeExpressionLanguageValidator(AttributeExpression.ResultType.STRING, true))
- .build();
- } else {
- return propertyBuilder
- .build();
- }
+ .dynamic(true)
+ .build();
}
@Override
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 f2220100f6..65ed24c71f 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
@@ -151,6 +151,13 @@ public class TestUpdateAttribute {
runner.getFlowFilesForRelationship(UpdateAttribute.REL_SUCCESS).get(0).assertAttributeEquals("NewAttr", "3");
}
+ @Test
+ public void testAddAttributeWithIncorrectExpression() throws Exception {
+ final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());
+ runner.setProperty("NewId", "${UUID(}");
+ runner.assertNotValid();
+ }
+
@Test
public void testBasicState() throws Exception {
final TestRunner runner = TestRunners.newTestRunner(new UpdateAttribute());