-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug
Milestone
Description
Dave Syer opened SPR-9495 and commented
MethodResolver results are cached in SpEL expressions, so changing the context has no effect. It's nice that there is some control over MethodResolver in StandardEvaluationContext, but because the results are cached in the expression itself (deep in MethodReference so no options I can see to override), they only have an effect once. Users are confused because they set a MethodResolver which apparently is ignored when passed into an expression at evaluation time:
Expression expression = parser.parseExpression("...");
StandardEvaluationContext context = new StandardEvaluationContext();
context.addMethodResolver(new SpiffyMethodResolver());
assertTrue(expression.getValue(context, Boolean.class));
context = new StandardEvaluationContext();
context.addMethodResolver(new CrappyMethodResolver());
assertFalse(expression.getValue(context, Boolean.class)); // FAIL! (it's using the result from the old resolver)
Affects: 3.1.1
Issue Links:
- SPEL and Enum variable resolution using wrong cachedExecutor [SPR-10452] #15085 SPEL and Enum variable resolution using wrong cachedExecutor
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: bugA general bugA general bug