You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by pv...@apache.org on 2019/10/30 08:59:22 UTC

[nifi] branch master updated: NIFI-4348 handled NPE in isExpressionLanguagePresent.

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

pvillard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 3d56e2f  NIFI-4348 handled NPE in isExpressionLanguagePresent.
3d56e2f is described below

commit 3d56e2f26d2943c00f4ffdfe8629c6faf8be4998
Author: mtien <mt...@gmail.com>
AuthorDate: Tue Oct 29 15:29:13 2019 -0700

    NIFI-4348 handled NPE in isExpressionLanguagePresent.
    
    Signed-off-by: Pierre Villard <pi...@gmail.com>
    
    This closes #3857.
---
 .../expression/language/StandardPropertyValue.java          |  3 +++
 .../apache/nifi/processor/TestStandardPropertyValue.java    | 13 +++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/StandardPropertyValue.java b/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/StandardPropertyValue.java
index 4ffce2b..2b3c863 100644
--- a/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/StandardPropertyValue.java
+++ b/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/StandardPropertyValue.java
@@ -207,6 +207,9 @@ public class StandardPropertyValue implements PropertyValue {
 
     @Override
     public boolean isExpressionLanguagePresent() {
+        if (preparedQuery == null) {
+            return false;
+        }
         return preparedQuery.isExpressionLanguagePresent();
     }
 }
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java
index 4d84730..be0ae24 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java
@@ -31,6 +31,7 @@ import java.util.Map;
 import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
 
 public class TestStandardPropertyValue {
@@ -123,6 +124,18 @@ public class TestStandardPropertyValue {
         assertEquals(year, val);
     }
 
+    @Test
+    public void testisExpressionLanguagePresentShouldHandleNPE() {
+        // Arrange
+        final PropertyValue value = new StandardPropertyValue(null, lookup, ParameterLookup.EMPTY, null, null);
+
+        // Act
+        boolean elPresent = value.isExpressionLanguagePresent();
+
+        // Assert
+        assertFalse(elPresent);
+    }
+
     private FlowFile createFlowFile(final Map<String, String> attributes) {
         return new StandardFlowFileRecord.Builder().addAttributes(attributes).build();
     }