You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (Jira)" <ji...@apache.org> on 2021/06/07 13:15:06 UTC
[jira] [Closed] (JEXL-324)
JexlEngine.createExpression("new()").getParsedText() throws NPE
[ https://issues.apache.org/jira/browse/JEXL-324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Biestro closed JEXL-324.
------------------------------
> 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)