Skip to content

Commit dd094b5

Browse files
committed
Complete removal of local variable support in SpEL
See gh-33809
1 parent af83a15 commit dd094b5

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ExpressionState.java

-55
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import java.util.ArrayDeque;
2020
import java.util.Deque;
21-
import java.util.HashMap;
2221
import java.util.List;
23-
import java.util.Map;
2422
import java.util.NoSuchElementException;
2523
import java.util.function.Supplier;
2624

@@ -64,9 +62,6 @@ public class ExpressionState {
6462
@Nullable
6563
private Deque<TypedValue> contextObjects;
6664

67-
@Nullable
68-
private Deque<VariableScope> variableScopes;
69-
7065
// When entering a new scope there is a new base object which should be used
7166
// for '#this' references (or to act as a target for unqualified references).
7267
// This ArrayDeque captures those objects at each nested scope level.
@@ -207,12 +202,10 @@ public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor
207202
* context object} and a new local variable scope.
208203
*/
209204
public void enterScope() {
210-
initVariableScopes().push(new VariableScope());
211205
initScopeRootObjects().push(getActiveContextObject());
212206
}
213207

214208
public void exitScope() {
215-
initVariableScopes().pop();
216209
initScopeRootObjects().pop();
217210
}
218211

@@ -231,15 +224,6 @@ private Deque<TypedValue> initScopeRootObjects() {
231224
return this.scopeRootObjects;
232225
}
233226

234-
private Deque<VariableScope> initVariableScopes() {
235-
if (this.variableScopes == null) {
236-
this.variableScopes = new ArrayDeque<>();
237-
// top-level empty variable scope
238-
this.variableScopes.add(new VariableScope());
239-
}
240-
return this.variableScopes;
241-
}
242-
243227
public TypedValue operate(Operation op, @Nullable Object left, @Nullable Object right) throws EvaluationException {
244228
OperatorOverloader overloader = this.relatedContext.getOperatorOverloader();
245229
if (overloader.overridesOperation(op, left, right)) {
@@ -265,43 +249,4 @@ public SpelParserConfiguration getConfiguration() {
265249
return this.configuration;
266250
}
267251

268-
269-
/**
270-
* A new local variable scope is entered when a new expression scope is
271-
* entered and exited when the corresponding expression scope is exited.
272-
*
273-
* <p>If variable names clash with those in a higher level scope, those in
274-
* the higher level scope will not be accessible within the current scope.
275-
*/
276-
private static class VariableScope {
277-
278-
private final Map<String, Object> variables = new HashMap<>();
279-
280-
VariableScope() {
281-
}
282-
283-
VariableScope(String name, Object value) {
284-
this.variables.put(name, value);
285-
}
286-
287-
VariableScope(@Nullable Map<String, Object> variables) {
288-
if (variables != null) {
289-
this.variables.putAll(variables);
290-
}
291-
}
292-
293-
@Nullable
294-
Object lookupVariable(String name) {
295-
return this.variables.get(name);
296-
}
297-
298-
void setVariable(String name, Object value) {
299-
this.variables.put(name,value);
300-
}
301-
302-
boolean definesVariable(String name) {
303-
return this.variables.containsKey(name);
304-
}
305-
}
306-
307252
}

0 commit comments

Comments
 (0)