-
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
SpEL: parsing exception when combining null-safe navigation and list indexing [SPR-16929] #21468
Comments
@aclement, ping. |
Well, if it's only matter of accessing null-safe first/last element |
I also want this feature, to support a safe index navigation. Just like groovy did in 3.0: use |
This syntax clashes with collection selection in case of collection is context root. Its hard to decide if |
However implementing syntax like |
|
This set of commits introduces support for a null-safe operator in the Spring Expression Language (SpEL), including support for compiling expressions that use the null-safe index operator. Note, however, that compilation is not supported for null-safe indexing into a String or any kind of Collection (other than a List). See gh-21468 Closes gh-29847
Juan Domínguez González opened SPR-16929 and commented
When parsing an expression which combines null-safe and list/array navigation it fails with a parse exception.
Example: accessing first element of a (possibly null) list/array of strings:
stringList?[0]
org.springframework.expression.spel.SpelParseException: EL1041E: After parsing a valid expression, there is still more data in the expression: 'select(?[)
I'm not sure if the syntax I've used is correct, but, to me it seems the most natural one.
Combining the null safe operator and navigation using get, seems to work: e.j:
stringList?.get(0)
Alternative syntaxes, such as
(stringList?)[0]
orstringList?.[0]
, also fail to compile..Affects: 4.3.16
The text was updated successfully, but these errors were encountered: