Skip to content

Commit 80fb8ea

Browse files
committed
Avoid unnecessary compilation attempts in SpEL's Indexer
Closes gh-32677
1 parent 1eed71b commit 80fb8ea

File tree

1 file changed

+6
-2
lines changed
  • spring-expression/src/main/java/org/springframework/expression/spel/ast

1 file changed

+6
-2
lines changed

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,11 @@ else if (target instanceof Collection<?> collection) {
355355

356356
@Override
357357
public boolean isCompilable() {
358+
if (this.exitTypeDescriptor == null) {
359+
return false;
360+
}
358361
if (this.indexedType == IndexedType.ARRAY) {
359-
return (this.exitTypeDescriptor != null && this.arrayTypeDescriptor != null);
362+
return (this.arrayTypeDescriptor != null);
360363
}
361364
SpelNodeImpl index = this.children[0];
362365
if (this.indexedType == IndexedType.LIST) {
@@ -792,10 +795,11 @@ public TypedValue getValue() {
792795
this.evaluationContext, this.targetObject, this.name);
793796
}
794797
updatePropertyReadState(accessor, this.name, targetType);
798+
TypedValue result = accessor.read(this.evaluationContext, this.targetObject, this.name);
795799
if (accessor instanceof CompilablePropertyAccessor compilablePropertyAccessor) {
796800
setExitTypeDescriptor(CodeFlow.toDescriptor(compilablePropertyAccessor.getPropertyType()));
797801
}
798-
return accessor.read(this.evaluationContext, this.targetObject, this.name);
802+
return result;
799803
}
800804
}
801805
}

0 commit comments

Comments
 (0)