New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StandardEvaluationContext does not support concurrent variable access [SPR-17448] #21980
Comments
Juergen Hoeller commented
Looking at your code, the |
chenzhiguo commented Juergen HoellerIf I need to use StandardEvaluationContext in multithreaded environment, are there any existing implementation classes? What happens now is that my system occasionally encounters a null exception. In my production environment, parseExpression is called multiple times and the expression template differ. |
Juergen Hoeller commented The key question is: Why are you sharing a mutable |
chenzhiguo commented Juergen Hoeller The usage scenario goes like this: I'm going to call N methods to get different data, and I am call these methods with same @Async
@Override
public <T> Future<T> doAsyncParser(String expression, Class<T> beanType) {
if (null == expression) {
expression = "";
}
return new AsyncResult<>(expressionParser.parseExpression(expression)
.getValue(evaluationContext, beanType));
} So, the anomaly described above has occurred.
|
Juergen Hoeller commented Since |
chenzhiguo opened SPR-17448 and commented
I invoke a method with SpEL. Sometimes, the param used by the method i invoke is null!!
I think the "StandardEvaluationContext"->variables = new HashMap<>(); Is it thread unsafe when the SpEL working?
So, I extend StandardEvaluationContext to MyEvaluationContext and it working properly.
But I'm not sure exactly why. I look forward to your reply.
Thanks.
Affects: 5.0.5
Issue Links:
Referenced from: commits 591e7f1, 59fa647
Backported to: 5.0.11
The text was updated successfully, but these errors were encountered: