diff options
author | Claude Brisson <cbrisson@apache.org> | 2018-10-14 13:33:57 +0000 |
---|---|---|
committer | Claude Brisson <cbrisson@apache.org> | 2018-10-14 13:33:57 +0000 |
commit | 8cc3695d7fbe0d7e18e85426d6f23ae4928d705b (patch) | |
tree | 6524c01639380a61bb26bfeb6447750f7c94f5fd /velocity-engine-core/src/main/java/org/apache | |
parent | 08b6d136010ec70b3761629dd6a8d39ba38e6df4 (diff) | |
download | apache-velocity-engine-8cc3695d7fbe0d7e18e85426d6f23ae4928d705b.tar.gz |
[VELOCITY-855] Fix methods caching for references of type Class
git-svn-id: https://svn.apache.org/repos/asf/velocity/engine/trunk@1843836 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'velocity-engine-core/src/main/java/org/apache')
-rw-r--r-- | velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java | 5 | ||||
-rw-r--r-- | velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java index c750d76e..65ba0e43 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTIdentifier.java @@ -137,6 +137,7 @@ public class ASTIdentifier extends SimpleNode */ IntrospectionCacheData icd = context.icacheGet(this); + Class clazz = o instanceof Class ? (Class)o : o.getClass(); /* * if we have the cache data and the class of the object we are @@ -145,7 +146,7 @@ public class ASTIdentifier extends SimpleNode * that is fixed in the template :) */ - if ( icd != null && (o != null) && (icd.contextData == o.getClass()) ) + if ( icd != null && (o != null) && (icd.contextData == clazz) ) { vg = (VelPropertyGet) icd.thingy; } @@ -161,7 +162,7 @@ public class ASTIdentifier extends SimpleNode if (vg != null && vg.isCacheable() && (o != null)) { icd = new IntrospectionCacheData(); - icd.contextData = o.getClass(); + icd.contextData = clazz; icd.thingy = vg; context.icachePut(this,icd); } diff --git a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java index 66e2ae72..3da7d228 100644 --- a/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java +++ b/velocity-engine-core/src/main/java/org/apache/velocity/util/ClassUtils.java @@ -181,12 +181,13 @@ public class ClassUtils { */ MethodCacheKey mck = new MethodCacheKey(methodName, paramClasses); IntrospectionCacheData icd = context.icacheGet(mck); + Class clazz = o instanceof Class ? (Class)o : o.getClass(); /* * like ASTIdentifier, if we have cache information, and the Class of * Object o is the same as that in the cache, we are safe. */ - if (icd != null && (o != null && icd.contextData == o.getClass())) + if (icd != null && (o != null && icd.contextData == clazz)) { /* @@ -205,7 +206,7 @@ public class ClassUtils { if ((method != null) && (o != null)) { icd = new IntrospectionCacheData(); - icd.contextData = o.getClass(); + icd.contextData = clazz; icd.thingy = method; context.icachePut(mck, icd); |