From 2fb213d26c554445c7df0c4b6e5c669200b831e3 Mon Sep 17 00:00:00 2001 From: Mike Thomsen Date: Thu, 31 May 2018 19:39:05 -0400 Subject: [PATCH] NIFI-5145 Fixed evaluateAttributeExpressions in mockpropertyvalue to make it handle null flowfiles. Signed-off-by: Matthew Burgess This closes #2749 --- .../java/org/apache/nifi/util/MockPropertyValue.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockPropertyValue.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockPropertyValue.java index a5df1a94f2..6e38a0847a 100644 --- a/nifi-mock/src/main/java/org/apache/nifi/util/MockPropertyValue.java +++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockPropertyValue.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.util; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -208,9 +209,13 @@ public class MockPropertyValue implements PropertyValue { * is running, it doesn't care when it's evaluating EL against a null flowfile. However, the testing framework currently * raises an error which makes it not mimick real world behavior. */ - if (flowFile == null) { - return evaluateAttributeExpressions(null, (Map)null); + if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) { + return evaluateAttributeExpressions(new HashMap<>()); + } else if (flowFile == null && expressionLanguageScope == ExpressionLanguageScope.VARIABLE_REGISTRY) { + return evaluateAttributeExpressions(); //Added this to get around a similar edge case where the a null flowfile is passed + //and the scope is to the registry } + return evaluateAttributeExpressions(flowFile, null, null); }