Skip to content

SPEL: Introduce a new null-safe access operator for properties [SPR-5664] #10335

@spring-projects-issues

Description

@spring-projects-issues

Oliver Becker opened SPR-5664 and commented

SPEL doesn't have a way to specify whether property accessors should be null safe or not.
Currently they are not null safe, i.e. "foo.bar" will throw an exception if foo is null. (However, there's an inconsistency here, see #10334)

It would be great if SPEL could introduce an additional operator '?.' (besides the '.' operator) for null-safe access.
Thus "foo.bar" would still throw an exception, but "foo?.bar" would evaluate to null resp. the default value of bar (for primitive types).

There's an interesting blog post about this idea at http://codervirtue.blogspot.com/2009/03/null-safe-invocation-in-java-7.html


Affects: 3.0 M2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions