-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
Document safe navigation semantics within compound expressions in SpEL #21827
Comments
Andy Clement commented This is actually working as designed right now. The expression from the test program is
There are actually two dereferences there:
The exception: |
Giulio Quaresima commented I thank you very much, I had not been understanding well the operator's semantics before: maybe its documentation is not so clear about these details. Actually, reading the documentation, the natural interpretation to me was that if an expression contained a reference to a Consider a such class: public class Bob
{
public String name = "Bob";
public Integer age = 14;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Integer getAge()
{
return age;
}
public void setAge(Integer age)
{
this.age = age;
}
} and an evaluation context with a |
Juan Domínguez González commented Just a note on this: supporting |
Andy Clement commented Yes, after further thinking, I think we could say for a compound expression the use of a null safe mechanism in the middle terminates the entire expression with null. (as in change the implementation to behave this way) |
:bump Any updates on fixing this? |
This comment was marked as outdated.
This comment was marked as outdated.
In order to avoid introducing additional complexity in the implementation of the Spring Expression Language, we have decided not to resolve an entire compound expression to In other words, use of the null-safe navigation operator is required on all nodes in a compound expression, which aligns with the behavior of other languages such as Groovy. I am therefore repurposing this ticket to document the current behavior. Furthermore, please note that we will introduce a null-safe index operator in Spring Framework 6.2. Related Issues |
Giulio Quaresima opened SPR-17294 and commented
When I use the Safe Navigation operator my expectation is that it is always safe to evaluate an expression with null values. But in some contexts I get the SpelEvaluationException with the message "EL1012E:(pos 11): Cannot index into a null value".
See the example attached.
Affects: 4.3.19
Attachments:
The text was updated successfully, but these errors were encountered: