From 34a81b605abfa2c2d9d62652a43fbc6bf38e3016 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 20 Jul 2015 13:04:34 +0200 Subject: [PATCH] PropertyOrFieldReference defensively catches Exception instead of just AccessException Issue: SPR-13247 --- .../spel/ast/PropertyOrFieldReference.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java index faae9ab2f6..89b9081db7 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/PropertyOrFieldReference.java @@ -187,9 +187,9 @@ public class PropertyOrFieldReference extends SpelNodeImpl { try { return accessorToUse.read(evalContext, contextObject.getValue(), name); } - catch (AccessException 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 + 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; } } @@ -212,7 +212,7 @@ public class PropertyOrFieldReference extends SpelNodeImpl { } } } - catch (AccessException ex) { + catch (Exception ex) { throw new SpelEvaluationException(ex, SpelMessage.EXCEPTION_DURING_PROPERTY_READ, name, ex.getMessage()); } } @@ -238,9 +238,9 @@ public class PropertyOrFieldReference extends SpelNodeImpl { accessorToUse.write(evalContext, contextObject.getValue(), name, newValue); return; } - catch (AccessException 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 + 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; } } @@ -291,7 +291,6 @@ public class PropertyOrFieldReference extends SpelNodeImpl { return false; } - // TODO when there is more time, remove this and use the version in AstUtils /** * Determines the set of property resolvers that should be used to try and access a property * on the specified target type. The resolvers are considered to be in an ordered list,