Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is SpelExpression in spring-el thread safe?

Expression exp = parser.parseExpression("myParam.getValue()");

Is the Expression class thread safe? I would like to store it in global cache, like ConcurrentHashMap to avoid compilation with every access.

like image 808
Maciej Miklas Avatar asked Oct 05 '22 00:10

Maciej Miklas


1 Answers

Well Expression is an interface, not a class. But, yes, if your parser is a standard SpelExpressionParser, the resulting SpelExpression implementation is thread-safe. In general, evaluation contexts are too, as long as you don't mutate them (e.g. changing variables, functions) while being used.

like image 161
Gary Russell Avatar answered Oct 13 '22 11:10

Gary Russell