[jboss-jira] [JBoss JIRA] (DROOLS-476) NPE when parsing arithmetic expression

Hassler Jean-Christian (JIRA) issues at jboss.org
Fri May 2 06:07:56 EDT 2014


Hassler Jean-Christian created DROOLS-476:
---------------------------------------------

             Summary: NPE when parsing arithmetic expression
                 Key: DROOLS-476
                 URL: https://issues.jboss.org/browse/DROOLS-476
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 5.5.0.Final
         Environment: sun JDK 1.6;
Drools 5.5.0Final
            Reporter: Hassler Jean-Christian
            Assignee: Mark Proctor


When user write computations with MVEL, mvel throw the error {color:red}[Error: not a statement, or badly formed structure] {color}at parsing time.
If you add parenthesis, parsing is OK.

The issue can be reproduced directly with the lastest MVEL version.

As you can see in the test below, same expression with parenthesis is OK. Debugging into mvel engine shows that there some nullPointerException in the bad case.

This issue was reproduced with the MVEL version embedded inside Drools 5.5.0Final and also with MVEL version 2.1.9.Final.

{code:java}
public class MvelTest {
      public void test(){
    	  
		String expressionThatDoesNotWork = "5 + 1/10 * (VAR - 5)"; // !!! mvel cannot parse this expression
		String expressionThatWorks = "5 + (1/10) * (VAR - 5)"; //with additionnal parenthesis it's OK
		
		Serializable parsingResultOK = MVEL.compileExpression(expressionThatWorks); //this works seamlessly 
		System.out.println(parsingResultOK); //=> (Literal<5> + (Literal<0.1> * (VAR - Literal<5>)))
		
		Serializable failedResult = MVEL.compileExpression(expressionThatDoesNotWork); // !!! this throws NullPointerException in MVEL engine
		
      }
}
{code}



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)


More information about the jboss-jira mailing list