Skip to content

Commit 34a81b6

Browse files
committed
PropertyOrFieldReference defensively catches Exception instead of just AccessException
Issue: SPR-13247
1 parent cad0665 commit 34a81b6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ private TypedValue readProperty(TypedValue contextObject, EvaluationContext eval
187187
try {
188188
return accessorToUse.read(evalContext, contextObject.getValue(), name);
189189
}
190-
catch (AccessException ex) {
191-
// this is OK - it may have gone stale due to a class change,
192-
// let's try to get a new one and call it before giving up
190+
catch (Exception ex) {
191+
// This is OK - it may have gone stale due to a class change,
192+
// let's try to get a new one and call it before giving up...
193193
this.cachedReadAccessor = null;
194194
}
195195
}
@@ -212,7 +212,7 @@ private TypedValue readProperty(TypedValue contextObject, EvaluationContext eval
212212
}
213213
}
214214
}
215-
catch (AccessException ex) {
215+
catch (Exception ex) {
216216
throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_DURING_PROPERTY_READ, name, ex.getMessage());
217217
}
218218
}
@@ -238,9 +238,9 @@ private void writeProperty(TypedValue contextObject, EvaluationContext evalConte
238238
accessorToUse.write(evalContext, contextObject.getValue(), name, newValue);
239239
return;
240240
}
241-
catch (AccessException ex) {
242-
// this is OK - it may have gone stale due to a class change,
243-
// let's try to get a new one and call it before giving up
241+
catch (Exception ex) {
242+
// This is OK - it may have gone stale due to a class change,
243+
// let's try to get a new one and call it before giving up...
244244
this.cachedWriteAccessor = null;
245245
}
246246
}
@@ -291,7 +291,6 @@ public boolean isWritableProperty(String name, TypedValue contextObject, Evaluat
291291
return false;
292292
}
293293

294-
// TODO when there is more time, remove this and use the version in AstUtils
295294
/**
296295
* Determines the set of property resolvers that should be used to try and access a property
297296
* on the specified target type. The resolvers are considered to be in an ordered list,

0 commit comments

Comments
 (0)