Skip to content

Commit 86d8163

Browse files
committed
Consistently invoke isNullSafe()
1 parent 80df88b commit 86d8163

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -166,7 +166,7 @@ private ValueRef getValueRef(ExpressionState state, AccessMode accessMode) throw
166166
Object target = context.getValue();
167167

168168
if (target == null) {
169-
if (this.nullSafe) {
169+
if (isNullSafe()) {
170170
return ValueRef.NullValueRef.INSTANCE;
171171
}
172172
// Raise a proper exception in case of a null target
@@ -330,7 +330,7 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
330330
}
331331

332332
Label skipIfNull = null;
333-
if (this.nullSafe) {
333+
if (isNullSafe()) {
334334
mv.visitInsn(DUP);
335335
skipIfNull = new Label();
336336
Label continueLabel = new Label();
@@ -439,7 +439,7 @@ private void setExitTypeDescriptor(String descriptor) {
439439
// If this indexer would return a primitive - and yet it is also marked
440440
// null-safe - then the exit type descriptor must be promoted to the box
441441
// type to allow a null value to be passed on.
442-
if (this.nullSafe && CodeFlow.isPrimitive(descriptor)) {
442+
if (isNullSafe() && CodeFlow.isPrimitive(descriptor)) {
443443
this.originalPrimitiveExitTypeDescriptor = descriptor;
444444
this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor);
445445
}

spring-expression/src/main/java/org/springframework/expression/spel/ast/MethodReference.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ private TypedValue getValueInternal(EvaluationContext evaluationContext,
160160
}
161161

162162
private void throwIfNotNullSafe(List<TypeDescriptor> argumentTypes) {
163-
if (!this.nullSafe) {
163+
if (!isNullSafe()) {
164164
throw new SpelEvaluationException(getStartPosition(),
165165
SpelMessage.METHOD_CALL_ON_NULL_OBJECT_NOT_ALLOWED,
166166
FormatHelper.formatMethodForMessage(this.name, argumentTypes));
@@ -258,7 +258,7 @@ private void updateExitTypeDescriptor() {
258258
if (executorToCheck != null && executorToCheck.get() instanceof ReflectiveMethodExecutor reflectiveMethodExecutor) {
259259
Method method = reflectiveMethodExecutor.getMethod();
260260
String descriptor = CodeFlow.toDescriptor(method.getReturnType());
261-
if (this.nullSafe && CodeFlow.isPrimitive(descriptor) && (descriptor.charAt(0) != 'V')) {
261+
if (isNullSafe() && CodeFlow.isPrimitive(descriptor) && (descriptor.charAt(0) != 'V')) {
262262
this.originalPrimitiveExitTypeDescriptor = descriptor.charAt(0);
263263
this.exitTypeDescriptor = CodeFlow.toBoxedDescriptor(descriptor);
264264
}
@@ -324,7 +324,7 @@ public void generateCode(MethodVisitor mv, CodeFlow cf) {
324324
}
325325

326326
Label skipIfNull = null;
327-
if (this.nullSafe && (descriptor != null || !isStatic)) {
327+
if (isNullSafe() && (descriptor != null || !isStatic)) {
328328
skipIfNull = new Label();
329329
Label continueLabel = new Label();
330330
mv.visitInsn(DUP);

spring-expression/src/main/java/org/springframework/expression/spel/ast/Projection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -131,7 +131,7 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
131131
}
132132

133133
if (operand == null) {
134-
if (this.nullSafe) {
134+
if (isNullSafe()) {
135135
return ValueRef.NullValueRef.INSTANCE;
136136
}
137137
throw new SpelEvaluationException(getStartPosition(), SpelMessage.PROJECTION_NOT_SUPPORTED_ON_TYPE, "null");

spring-expression/src/main/java/org/springframework/expression/spel/ast/Selection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -199,7 +199,7 @@ protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
199199
}
200200

201201
if (operand == null) {
202-
if (this.nullSafe) {
202+
if (isNullSafe()) {
203203
return ValueRef.NullValueRef.INSTANCE;
204204
}
205205
throw new SpelEvaluationException(getStartPosition(), SpelMessage.INVALID_TYPE_FOR_SELECTION, "null");

0 commit comments

Comments
 (0)