2014-02-06 4 views
0
public class MvelTest { 
    @Test 
    public void testNullDivision() { 
     String expression = "2/null"; 
     Serializable compiledExpression = MVEL.compileExpression(expression, new ParserContext()); 
     Object value = MVEL.executeExpression(compiledExpression); 
     System.out.print(value); // false! 
    } 
} 

Отдел по null возвращает false в MVEL. Но почему? mvel2-2.1.3.FinalДеление на null в MVEL возвращает false. Какова логика этого?

ответ

0
If you actually debug this in Mvel API classes, they are explicitly returning false for this particular case. 
If Mvel can fix this, it will be good. But this same issue i also encountered, so what we did, we created some intelligence before executing the expression, we modified the expression and included "IF" condition to check for the fields that are null and having operator as "/" or "*", the return null. 
Смежные вопросы