Consistently invoke isNullSafe()
This commit is contained in:
parent
80df88bd4f
commit
86d81632c8
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -166,7 +166,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
Object target = context.getValue();
|
||||
|
||||
if (target == null) {
|
||||
if (this.nullSafe) {
|
||||
if (isNullSafe()) {
|
||||
return ValueRef.NullValueRef.INSTANCE;
|
||||
}
|
||||
// Raise a proper exception in case of a null target
|
||||
|
@ -330,7 +330,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
Label skipIfNull = null;
|
||||
if (this.nullSafe) {
|
||||
if (isNullSafe()) {
|
||||
mv.visitInsn(DUP);
|
||||
skipIfNull = new Label();
|
||||
Label continueLabel = new Label();
|
||||
|
@ -439,7 +439,7 @@ public class Indexer extends SpelNodeImpl {
|
|||
// If this indexer would return a primitive - and yet 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.
|
||||
if (this.nullSafe && CodeFlow.isPrimitive(descriptor)) {
|
||||
if (isNullSafe() && CodeFlow.isPrimitive(descriptor)) {
|
||||
this.originalPrimitiveExitTypeDescriptor = descriptor;
|
||||
this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor);
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ public class MethodReference extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
private void throwIfNotNullSafe(List<TypeDescriptor> argumentTypes) {
|
||||
if (!this.nullSafe) {
|
||||
if (!isNullSafe()) {
|
||||
throw new SpelEvaluationException(getStartPosition(),
|
||||
SpelMessage.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
|
||||
FormatHelper.formatMethodForMessage(this.name, argumentTypes));
|
||||
|
@ -258,7 +258,7 @@ public class MethodReference extends SpelNodeImpl {
|
|||
if (executorToCheck != null && executorToCheck.get() instanceof ReflectiveMethodExecutor reflectiveMethodExecutor) {
|
||||
Method method = reflectiveMethodExecutor.getMethod();
|
||||
String descriptor = CodeFlow.toDescriptor(method.getReturnType());
|
||||
if (this.nullSafe && CodeFlow.isPrimitive(descriptor) && (descriptor.charAt(0) != 'V')) {
|
||||
if (isNullSafe() && CodeFlow.isPrimitive(descriptor) && (descriptor.charAt(0) != 'V')) {
|
||||
this.originalPrimitiveExitTypeDescriptor = descriptor.charAt(0);
|
||||
this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor);
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class MethodReference extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
Label skipIfNull = null;
|
||||
if (this.nullSafe && (descriptor != null || !isStatic)) {
|
||||
if (isNullSafe() && (descriptor != null || !isStatic)) {
|
||||
skipIfNull = new Label();
|
||||
Label continueLabel = new Label();
|
||||
mv.visitInsn(DUP);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -131,7 +131,7 @@ public class Projection extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
if (operand == null) {
|
||||
if (this.nullSafe) {
|
||||
if (isNullSafe()) {
|
||||
return ValueRef.NullValueRef.INSTANCE;
|
||||
}
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE, "null");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -199,7 +199,7 @@ public class Selection extends SpelNodeImpl {
|
|||
}
|
||||
|
||||
if (operand == null) {
|
||||
if (this.nullSafe) {
|
||||
if (isNullSafe()) {
|
||||
return ValueRef.NullValueRef.INSTANCE;
|
||||
}
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INVALID_TYPE_FOR_SELECTION, "null");
|
||||
|
|
Loading…
Reference in New Issue