Avoid unnecessary compilation attempts in SpEL's Indexer
Closes gh-32677
This commit is contained in:
parent
1eed71bb1d
commit
80fb8ea813
|
|
@ -355,8 +355,11 @@ public class Indexer extends SpelNodeImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompilable() {
|
public boolean isCompilable() {
|
||||||
|
if (this.exitTypeDescriptor == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (this.indexedType == IndexedType.ARRAY) {
|
if (this.indexedType == IndexedType.ARRAY) {
|
||||||
return (this.exitTypeDescriptor != null && this.arrayTypeDescriptor != null);
|
return (this.arrayTypeDescriptor != null);
|
||||||
}
|
}
|
||||||
SpelNodeImpl index = this.children[0];
|
SpelNodeImpl index = this.children[0];
|
||||||
if (this.indexedType == IndexedType.LIST) {
|
if (this.indexedType == IndexedType.LIST) {
|
||||||
|
|
@ -792,10 +795,11 @@ public class Indexer extends SpelNodeImpl {
|
||||||
this.evaluationContext, this.targetObject, this.name);
|
this.evaluationContext, this.targetObject, this.name);
|
||||||
}
|
}
|
||||||
updatePropertyReadState(accessor, this.name, targetType);
|
updatePropertyReadState(accessor, this.name, targetType);
|
||||||
|
TypedValue result = accessor.read(this.evaluationContext, this.targetObject, this.name);
|
||||||
if (accessor instanceof CompilablePropertyAccessor compilablePropertyAccessor) {
|
if (accessor instanceof CompilablePropertyAccessor compilablePropertyAccessor) {
|
||||||
setExitTypeDescriptor(CodeFlow.toDescriptor(compilablePropertyAccessor.getPropertyType()));
|
setExitTypeDescriptor(CodeFlow.toDescriptor(compilablePropertyAccessor.getPropertyType()));
|
||||||
}
|
}
|
||||||
return accessor.read(this.evaluationContext, this.targetObject, this.name);
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue