StandardEvaluationContext.setVariable leniently ignores null name

Issue: SPR-17565
This commit is contained in:
Juergen Hoeller 2018-12-05 14:13:24 +01:00
parent 7a5f8e03bc
commit db63f7dd4a
1 changed files with 11 additions and 6 deletions

View File

@ -229,12 +229,17 @@ public class StandardEvaluationContext implements EvaluationContext {
}
@Override
public void setVariable(String name, @Nullable Object value) {
if (value != null) {
this.variables.put(name, value);
}
else {
this.variables.remove(name);
public void setVariable(@Nullable String name, @Nullable Object value) {
// For backwards compatibility, we ignore null names here...
// And since ConcurrentHashMap cannot store null values, we simply take null
// as a remove from the Map (with the same result from lookupVariable below).
if (name != null) {
if (value != null) {
this.variables.put(name, value);
}
else {
this.variables.remove(name);
}
}
}