diff --git a/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java b/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java index 6867202ad0..c4b14bb646 100644 --- a/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java +++ b/nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/NumberToDateEvaluator.java @@ -37,7 +37,7 @@ public class NumberToDateEvaluator extends DateEvaluator { final QueryResult result = subject.evaluate(attributes); final Long value = result.getValue(); if (value == null) { - return null; + return new DateQueryResult(null); } return new DateQueryResult(new Date(value)); diff --git a/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java b/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java index 03de38f987..5946aa5b31 100644 --- a/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java +++ b/nifi-commons/nifi-expression-language/src/test/java/org/apache/nifi/attribute/expression/language/TestQuery.java @@ -898,6 +898,9 @@ public class TestQuery { verifyEquals("${entryDate:toNumber():toDate():format('yyyy')}", attributes, String.valueOf(year)); + // test for not existing attribute (NIFI-1962) + assertEquals("", Query.evaluateExpressions("${notExistingAtt:toDate()}", attributes, null)); + attributes.clear(); attributes.put("month", "3"); attributes.put("day", "4");