Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-476

NPE when MVEL parses arithmetic expression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 5.5.0.Final
    • None

    Description

      When user write computations with MVEL, mvel throw the error [Error: not a statement, or badly formed structure] 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.

      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
      		
            }
      }
      

      Attachments

        Activity

          People

            mproctor@redhat.com Mark Proctor
            jc.hassler Hassler Jean-Christian (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: