Closed
Description
Peter Luttrell opened SPR-15878 and commented
This is a feature request to add support for Java 8 Optionals to the Spring Expression Language.
One use case that I just ran into is wanting to use @PostAuthorize
on a method that returns an Optional in conjunctions with custom expressions. For example the following fails:
@PostAuthorize("canAccessOrganization(returnObject.organiztionId)")
public Optional<Person> getPerson(String personId){
...
}
In this case, if the returned reference isn't present, that @PostAuthorize
would allow the response, which should be Optional.empty(). If it is present, then it'd be dereferenced into the returnObject, so we'd have direct access to its fields for use in the expression.
4 votes, 6 watchers