PropertyOrFieldReference checks cached PropertyAccessor against current EvaluationContext
Issue: SPR-15769
This commit is contained in:
@@ -172,14 +172,16 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
||||
|
||||
PropertyAccessor accessorToUse = this.cachedReadAccessor;
|
||||
if (accessorToUse != null) {
|
||||
try {
|
||||
return accessorToUse.read(evalContext, contextObject.getValue(), name);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// This is OK - it may have gone stale due to a class change,
|
||||
// let's try to get a new one and call it before giving up...
|
||||
this.cachedReadAccessor = null;
|
||||
if (evalContext.getPropertyAccessors().contains(accessorToUse)) {
|
||||
try {
|
||||
return accessorToUse.read(evalContext, contextObject.getValue(), name);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// This is OK - it may have gone stale due to a class change,
|
||||
// let's try to get a new one and call it before giving up...
|
||||
}
|
||||
}
|
||||
this.cachedReadAccessor = null;
|
||||
}
|
||||
|
||||
List<PropertyAccessor> accessorsToTry =
|
||||
@@ -225,15 +227,17 @@ public class PropertyOrFieldReference extends SpelNodeImpl {
|
||||
|
||||
PropertyAccessor accessorToUse = this.cachedWriteAccessor;
|
||||
if (accessorToUse != null) {
|
||||
try {
|
||||
accessorToUse.write(evalContext, contextObject.getValue(), name, newValue);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// This is OK - it may have gone stale due to a class change,
|
||||
// let's try to get a new one and call it before giving up...
|
||||
this.cachedWriteAccessor = null;
|
||||
if (evalContext.getPropertyAccessors().contains(accessorToUse)) {
|
||||
try {
|
||||
accessorToUse.write(evalContext, contextObject.getValue(), name, newValue);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// This is OK - it may have gone stale due to a class change,
|
||||
// let's try to get a new one and call it before giving up...
|
||||
}
|
||||
}
|
||||
this.cachedWriteAccessor = null;
|
||||
}
|
||||
|
||||
List<PropertyAccessor> accessorsToTry =
|
||||
|
||||
Reference in New Issue
Block a user