NIFI-1962 - Fixed NPE in toDate() EL function

This closes #1409.

Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
Pierre Villard 2017-01-11 02:12:07 +01:00 committed by Koji Kawamura
parent bbc714e73b
commit 7a2751bf5d
2 changed files with 4 additions and 1 deletions

View File

@ -37,7 +37,7 @@ public class NumberToDateEvaluator extends DateEvaluator {
final QueryResult<Long> result = subject.evaluate(attributes);
final Long value = result.getValue();
if (value == null) {
return null;
return new DateQueryResult(null);
}
return new DateQueryResult(new Date(value));

View File

@ -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");