Issue with type conversion in SpelVariableExpressionEvaluator

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Issue with type conversion in SpelVariableExpressionEvaluator

Adrian Riley
SpelVariableExpressionEvaluator uses a Spring StandardEvaluationContext, created within the class and therefore not configurable. Type conversion is delegated to that class, which uses a StandardTypeConverter. When evaluating a variable in an spel expression, ReflectiveMethodExecutor.execute uses ReflectionHelper.convertArguments, which uses that StandardTypeConverter, to create a copy of the referenced variable (even when the variable is actually of the required type).

The problem I have found is that my variable's class implements Map, and the type converter uses the generic MapToMapConverter which tries to create a new instance of the class as the "converted" value,. That tries to invoke the no-arg constructor on the class, but this particular class doesn't have one. The end result of all this is a TemplateProcessingException.

I think maybe SpelVariableExpressionEvaluator might get the Spring conversion service to use, instead of this unconfigurable StandardTypeConverter. Or maybe there's some configuration option I'm missing which would resolve the problem?