StandardEvaluationContext supports concurrent variable modification
Issue: SPR-17448
This commit is contained in:
parent
0a7dcf14f9
commit
59fa647e2d
|
|
@ -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<>();
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue