-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject null and empty SpEL expressions #30371
Comments
Why |
NullPointerException
in InternalSpelExpressionParser
NullPointerException
in InternalSpelExpressionParser
NullPointerException
if SpEL expression is null
The
Interestingly enough, prior to #30325, the following test passed. @Test
void nullExpression() {
ExpressionParser parser = new SpelExpressionParser();
String expression = null;
Expression expr = parser.parseExpression(expression);
Object result = expr.getValue();
assertThat(result).isNull();
} However, that was not by design. Rather, that was by accident. Supplying a We currently do not have any planned releases for 5.2.x. Thus if you are encountering this issue with Spring Framework 5.2.x, please ensure that you do not supply a For Spring Framework 5.3.x and 6.x, I think we should introduce an explicit |
In light of the above, I am repurposing this ticket to fail early if |
NullPointerException
if SpEL expression is null
Prior to gh-30325, supplying a null reference for a SpEL expression was effectively equivalent to supplying the String "null" as the expression. Consequently, evaluation of a null reference expression always evaluated to a null reference. However, that was accidental rather than by design. Due to the introduction of the checkExpressionLength(String) method in InternalSpelExpressionParser (in conjunction with gh-30325), an attempt to evaluate a null reference as a SpEL expression now results in a NullPointerException. To address both of these issues, TemplateAwareExpressionParser.parseExpression() and SpelExpressionParser.parseRaw() now reject null and empty SpEL expressions. See gh-30371 Closes gh-30373
We have upgraded from Spring Framework 5.2.23 to 5.2.24, and now we are getting some
NullPointerException
s.Looking in the stack traces we find that the issue is in
InternalSpelExpressionParser
.With 5.2.24 there is now a 'checkExpressionLength(expressionString);' which calls:
If
string
isnull
thenstring.length()
results in aNullPointerException
.Is this the intended behavior of
checkExpressionLength()
, or is this a bug?The text was updated successfully, but these errors were encountered: