Protect against missing SpEL selection expression

Update InternalSpelExpressionParser to ensure that SPeL selections
('$[...]', '^[...]', '?[...]') always include a nested expression.

Issue: SPR-10328
This commit is contained in:
Phillip Webb
2013-02-25 14:25:47 -08:00
parent 9a6c6b9ee6
commit 82bd06f255
4 changed files with 19 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ import static org.junit.Assert.fail;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -1744,6 +1745,14 @@ public class SpelReproTests extends ExpressionTestCase {
parseExpression.getValue(context);
}
@Test
public void SPR_10328() throws Exception {
thrown.expect(SpelParseException.class);
thrown.expectMessage("EL1071E:(pos 2): A required selection expression has not been specified");
Expression exp = parser.parseExpression("$[]");
exp.getValue(Arrays.asList("foo", "bar", "baz"));
}
public static class BooleanHolder {
private Boolean simpleProperty = true;