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

Henri Biestro edited comment on JEXL-221 at 3/8/17 7:03 PM:
------------------------------------------------------------

Good catch, thanks!
Found how to reproduce; this occurs on the 3rd execution of a script that 
accesses a map with null as a key on its 2nd, i.e. uses a map executor with a 
null key argument. The executor is cached on the second execution (due to 
another bug in checkLoaderVersion that clears the script cache on the 2nd) and 
when reused by on the 3rd tryInvoke, NPE.
I'll commit a fix momentarily.



was (Author: henrib):
Good catch, thanks!
Found how to reproduce; this occurs on the 3rd execution of a script that 
accesses a map with null as a key on its 2nd, i.e. uses a map executor with a 
null key argument. The executor is cached on the second execution (due to 
another bug in checkLoaderVersion that clears the script cache on the 1st!) and 
when reused by on the 3rd tryInvoke, NPE.
I'll commit a fix momentarily.


> Sporadic undefined property error caused by NPE at MapGetExecutor.tryInvoke()
> -----------------------------------------------------------------------------
>
>                 Key: JEXL-221
>                 URL: https://issues.apache.org/jira/browse/JEXL-221
>             Project: Commons JEXL
>          Issue Type: Bug
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>
> I'm getting sporadic undefined property error when accessing hashmap by a 
> key. The stack trace tells the cause is NPE in MapGetExecutor.tryInvoke() at 
> the following line:
> {code}
>         if (obj != null && method != null
>                 && objectClass.equals(obj.getClass())
>                 && (key == null || 
> property.getClass().equals(key.getClass()))) {
> {code}
> I have managed to overcome this issue by adding the following null check:
> {code}
>         if (obj != null && method != null
>                 && objectClass.equals(obj.getClass())
>                 && (key == null || property != null && 
> property.getClass().equals(key.getClass()))) {
> {code}
> I have only vague understanding of how things work inside jexl with 
> tryInvoke() and unfortunately can not provide any test case for this, but it 
> has worked in my case, so if nobody have any objections please include the 
> fix in source tree.
> Thanks!



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to