mirror of https://github.com/apache/nifi.git
NIFI-1962 - Fixed NPE in toDate() EL function
This closes #1409. Signed-off-by: Koji Kawamura <ijokarumawak@apache.org>
This commit is contained in:
parent
bbc714e73b
commit
7a2751bf5d
|
@ -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));
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue