[
https://issues.apache.org/jira/browse/JEXL-324?focusedWorklogId=378889&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-378889
]
ASF GitHub Bot logged work on JEXL-324:
---------------------------------------
Author: ASF GitHub Bot
Created on: 29/Jan/20 15:54
Start Date: 29/Jan/20 15:54
Worklog Time Spent: 10m
Work Description: henrib commented on pull request #20: JEXL-324 - Change
grammar to make "new" require at least one argument
URL: https://github.com/apache/commons-jexl/pull/20
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 378889)
Time Spent: 20m (was: 10m)
> JexlEngine.createExpression("new()").getParsedText() throws NPE
> ---------------------------------------------------------------
>
> Key: JEXL-324
> URL: https://issues.apache.org/jira/browse/JEXL-324
> Project: Commons JEXL
> Issue Type: Bug
> Affects Versions: 3.1
> Reporter: David Costanzo
> Assignee: Henri Biestro
> Priority: Minor
> Fix For: 3.2
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> JEXL is able to parse the expression "new()", but some parts of the system do
> not expect this. Specifically, if you try to get the parsed text, JEXL
> throws a NullPointerException instead of returning "new()".
> I expect {{JexlExpression.getParsedText()}} to return a String for any
> expression that was successfully parsed. So either {{createExpression()}}
> should throw an exception or {{getParsedText()}} should return "new()". My
> preference is for {{createExpression()}} to fail and I'll try to submit a PR
> for this.
>
> *Impact:*
> My program tries to fail fast with a clear error message when a user attempts
> to "register" a function using a reserved name (function registration happens
> outside of JEXL and is implemented by populating a JexlContext with a parsed
> expression). My program does this by probing for valid function names by
> parsing {{_FUNCTION_NAME_+"()"}} and checking for errors. Since "new()" is a
> legal expression, my program has a special case to disallow "new". If
> {{createExpression("new()")}} threw an exception, then I could remove the
> special case.
>
> *Steps to Reproduce:*
>
> {code:java}
> @Test
> public void testNew() throws IOException {
> JexlEngine jexl = new JexlBuilder().create();
> try {
> JexlExpression expression = jexl.createExpression("new()");
> Assert.assertEquals("new()", expression.getParsedText());
> } catch (JexlException.Parsing exception) {
> }
> }
> {code}
>
> *What Happens:*
> {{getParsedText()}} throws a {{NullPointerException}}.
> *Expected Result:*
> Either {{JexlEngine.createExpression()}} throws a {{JexlException.Parsing}}
> or {{expression.getParsedText()}} returns "new()".
> *Note:*
> This was found on JEXL 3.1, the latest official release. I reproduced it on a
> snapshot of JEXL 3.2 built from GitHub source.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)