-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed as not planned
Closed as not planned
Copy link
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
@Test
public void testSpel(){
String expression = "#name == 'joy' || #age > 10 || #ab.type == 1 || #a == 10";
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("age", 8);
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariables(paramMap);
ExpressionParser parser = new SpelExpressionParser();
org.springframework.expression.Expression exp = parser.parseExpression(expression);
Object result = exp.getValue(context);
System.out.println(result);
}I expect the result output to be false, but an exception is thrown. Can this situation be optimized, when encountering non-existent data, it should be judged as unsatisfied instead of throwing an exception?
ERROR:
Exception in thread "main" org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'type' cannot be found on null
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:219)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:106)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:53)
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:412)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:93)
at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:42)
at org.springframework.expression.spel.ast.OpEQ.getValueInternal(OpEQ.java:32)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:212)
at org.springframework.expression.spel.ast.OpOr.getBooleanValue(OpOr.java:56)
at org.springframework.expression.spel.ast.OpOr.getValueInternal(OpOr.java:51)
at org.springframework.expression.spel.ast.OpOr.getValueInternal(OpOr.java:37)
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:114)
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:273)
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: invalidAn issue that we don't feel is validAn issue that we don't feel is valid