[ 
https://issues.apache.org/jira/browse/NIFI-1962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15824780#comment-15824780
 ] 

ASF GitHub Bot commented on NIFI-1962:
--------------------------------------

Github user ijokarumawak commented on the issue:

    https://github.com/apache/nifi/pull/1409
  
    Thanks @pvillard31 for tackling this. I reviewed the code and tested. While 
this PR fixes toDate to work even when an attribute value is null, there's 
another method that throws NPE, that is StandardAttributeExpression.evaluate. 
It has similar code.
    
    Also, I felt that changing Query class is too much for fixing a particular 
toDate EL function. Besides that, when I tested toNumber passing a non-existing 
attribute, it works fine, before applying this fix.
    
    So I looked at the code closer and found NumberToDateEvaluator may be the 
one should be fixed, because functions below react against null input value as 
followings:
    
    - NumberToDateEvaluator returns `null` <-- We probably need to fix this to 
return new DateQueryResult(null)
    - StringToDateEvaluator returns new DateQueryResult(null)
    - WholeNumberCastEvaluator returns new WholeNumberQueryResult(null) : this 
is an implementation for toNumber() function
    
    It seems returning XXXQueryResult(null) is a convention in EL functions 
when input is null.
    
    How do you think?


> NPE in Expression Language toDate()
> -----------------------------------
>
>                 Key: NIFI-1962
>                 URL: https://issues.apache.org/jira/browse/NIFI-1962
>             Project: Apache NiFi
>          Issue Type: Bug
>            Reporter: Brandon DeVries
>            Assignee: Pierre Villard
>            Priority: Minor
>
> attempting to call the toDate() expression language method on a non existent 
> attribute results in an NullPointerException.  
> {code}
> ${newAttribute:toDate()}
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to