Revise PropertyOrFieldReference since isNullSafe() is not final

This commit is contained in:
Sam Brannen 2024-03-22 16:22:41 +01:00
parent c7c61e13e1
commit d4495a5654
1 changed files with 4 additions and 4 deletions

View File

@ -181,7 +181,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
throws EvaluationException { throws EvaluationException {
Object targetObject = contextObject.getValue(); Object targetObject = contextObject.getValue();
if (targetObject == null && this.nullSafe) { if (targetObject == null && isNullSafe()) {
return TypedValue.NULL; return TypedValue.NULL;
} }
@ -233,7 +233,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
TypedValue contextObject, EvaluationContext evalContext, String name, @Nullable Object newValue) TypedValue contextObject, EvaluationContext evalContext, String name, @Nullable Object newValue)
throws EvaluationException { throws EvaluationException {
if (contextObject.getValue() == null && this.nullSafe) { if (contextObject.getValue() == null && isNullSafe()) {
return; return;
} }
if (contextObject.getValue() == null) { if (contextObject.getValue() == null) {
@ -353,7 +353,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
} }
Label skipIfNull = null; Label skipIfNull = null;
if (this.nullSafe) { if (isNullSafe()) {
mv.visitInsn(DUP); mv.visitInsn(DUP);
skipIfNull = new Label(); skipIfNull = new Label();
Label continueLabel = new Label(); Label continueLabel = new Label();
@ -381,7 +381,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
// If this property or field access would return a primitive - and yet // If this property or field access would return a primitive - and yet
// it is also marked null safe - then the exit type descriptor must be // it is also marked null safe - then the exit type descriptor must be
// promoted to the box type to allow a null value to be passed on // promoted to the box type to allow a null value to be passed on
if (this.nullSafe && CodeFlow.isPrimitive(descriptor)) { if (isNullSafe() && CodeFlow.isPrimitive(descriptor)) {
this.originalPrimitiveExitTypeDescriptor = descriptor; this.originalPrimitiveExitTypeDescriptor = descriptor;
this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor); this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor);
} }