mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
This commit introduces support for limiting the structural nesting depth of a SpEL expression during parsing. Without such a limit, an expression with deeply nested constructs (for example, inline lists or maps, parenthesized expressions, ternary or Elvis expressions, or chained unary operators) can cause SpEL's recursive-descent parser to throw a StackOverflowError which lacks useful diagnostics for developer's attempting to assess what went wrong. With this commit, a nesting-depth counter is now tracked around the parser's primary recursive entry point (eatExpression()) as well as around chained unary operators (eatUnaryExpression()), ensuring that independent, sibling uses of assignment, Elvis, and ternary expressions do not inadvertently accumulate depth and trip the limit. If the configured (or default) nesting-depth limit is exceeded during parsing, a SpelParseException is thrown instead, with a message that reports the configured limit. The limit can be configured on a per-use-case basis via SpelParserConfiguration and defaults to 1000. Closes gh-36723