Deprecate local variable support in SpEL's internal ExpressionState

Since the Spring Expression Language does not actually support local
variables in expressions, this commit deprecates all public APIs
related to local variables in ExpressionState (namely, the two
enterScope(...) variants that accept local variable data,
setLocalVariable(), and lookupLocalVariable()).

In addition, we no longer invoke `state.enterScope("index", ...)` in
the Projection and Selection AST nodes since the $index local variable
was never accessible within expressions anyway.

See gh-23202
Closes gh-32004
This commit is contained in:
Sam Brannen
2024-02-16 18:26:17 +01:00
parent c1f0faade7
commit ab48ac36e9
4 changed files with 15 additions and 4 deletions

View File

@@ -56,6 +56,7 @@ class ExpressionStateTests extends AbstractExpressionTests {
}
@Test
@SuppressWarnings("removal")
void localVariables() {
Object value = state.lookupLocalVariable("foo");
assertThat(value).isNull();
@@ -86,6 +87,7 @@ class ExpressionStateTests extends AbstractExpressionTests {
}
@Test
@SuppressWarnings("removal")
void noVariableInterference() {
TypedValue typedValue = state.lookupVariable("foo");
assertThat(typedValue).isEqualTo(TypedValue.NULL);
@@ -99,6 +101,7 @@ class ExpressionStateTests extends AbstractExpressionTests {
}
@Test
@SuppressWarnings("removal")
void localVariableNestedScopes() {
assertThat(state.lookupLocalVariable("foo")).isNull();
@@ -157,6 +160,7 @@ class ExpressionStateTests extends AbstractExpressionTests {
}
@Test
@SuppressWarnings("removal")
void populatedNestedScopes() {
assertThat(state.lookupLocalVariable("foo")).isNull();
@@ -186,6 +190,7 @@ class ExpressionStateTests extends AbstractExpressionTests {
}
@Test
@SuppressWarnings("removal")
void populatedNestedScopesMap() {
assertThat(state.lookupLocalVariable("foo")).isNull();
assertThat(state.lookupLocalVariable("goo")).isNull();