Skip to content
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

Introduce common support for is-null-safe checks in SpEL nodes #32516

Closed
sbrannen opened this issue Mar 22, 2024 · 0 comments
Closed

Introduce common support for is-null-safe checks in SpEL nodes #32516

sbrannen opened this issue Mar 22, 2024 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Mar 22, 2024

Overview

MethodReference and PropertyOrFieldReference already define local isNullSafe() methods, but we now need identical methods in Selection, Projection, and Indexer, and we may potentially need null-safe support for additional operators in the future.

However, doing so without a common mechanism will result in an if-block that's required to check each concrete node type separately.

In other words, the current if-block:

if ((nextChild instanceof MethodReference methodRef && methodRef.isNullSafe()) ||
(nextChild instanceof PropertyOrFieldReference pofRef && pofRef.isNullSafe())) {

... would grow to something similar to the following:

if ((nextChild instanceof MethodReference methodRef && methodRef.isNullSafe()) ||
		(nextChild instanceof PropertyOrFieldReference pofRef && pofRef.isNullSafe()) ||
		(nextChild instanceof Selection selection && selection.isNullSafe()) ||
		(nextChild instanceof Projection projection && projection.isNullSafe()) ||
		(nextChild instanceof Indexer indexer && indexer.isNullSafe())) {

Whereas, something unified like the following would be preferred.

if (nextChild.isNullSafe()) {

Prerequisite For

@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels Mar 22, 2024
@sbrannen sbrannen added this to the 6.1.6 milestone Mar 22, 2024
@sbrannen sbrannen self-assigned this Mar 22, 2024
@sbrannen sbrannen changed the title Introduce NullSafeOperation interface in SpEL Introduce common support for is-null-safe checks in SpEL nodes Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant