StandardEvaluationContext supports concurrent variable modification

Issue: SPR-17448

(cherry picked from commit 59fa647e2d)
This commit is contained in:
Juergen Hoeller
2018-11-05 12:26:35 +01:00
parent c834790135
commit 591e7f1f72

View File

@@ -18,9 +18,9 @@ package org.springframework.expression.spel.support;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.expression.BeanResolver;
@@ -88,7 +88,7 @@ public class StandardEvaluationContext implements EvaluationContext {
private OperatorOverloader operatorOverloader = new StandardOperatorOverloader();
private final Map<String, Object> variables = new HashMap<>();
private final Map<String, Object> variables = new ConcurrentHashMap<>();
/**
@@ -203,7 +203,7 @@ public class StandardEvaluationContext implements EvaluationContext {
@Override
public TypeConverter getTypeConverter() {
if (this.typeConverter == null) {
this.typeConverter = new StandardTypeConverter();
this.typeConverter = new StandardTypeConverter();
}
return this.typeConverter;
}
@@ -230,11 +230,16 @@ public class StandardEvaluationContext implements EvaluationContext {
@Override
public void setVariable(String name, @Nullable Object value) {
this.variables.put(name, value);
if (value != null) {
this.variables.put(name, value);
}
else {
this.variables.remove(name);
}
}
public void setVariables(Map<String,Object> variables) {
this.variables.putAll(variables);
public void setVariables(Map<String, Object> variables) {
variables.forEach(this::setVariable);
}
public void registerFunction(String name, Method method) {