Skip to content

Commit fe69771

Browse files
authored
Merge pull request #1578 from apache/WW-5614-proxy-memory
WW-5614 Remove cache for ProxyUtil#ultimateTargetClass
2 parents fd87425 + 11bc215 commit fe69771

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

core/src/main/java/org/apache/struts2/util/ProxyUtil.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public class ProxyUtil {
5454
CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, CACHE_INITIAL_CAPACITY).buildOgnlCache();
5555
private static final OgnlCache<Member, Boolean> isProxyMemberCache = new DefaultOgnlCacheFactory<Member, Boolean>(
5656
CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, CACHE_INITIAL_CAPACITY).buildOgnlCache();
57-
private static final OgnlCache<Object, Class<?>> targetClassCache = new DefaultOgnlCacheFactory<Object, Class<?>>(
58-
CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, CACHE_INITIAL_CAPACITY).buildOgnlCache();
5957

6058
/**
6159
* Determine the ultimate target class of the given instance, traversing
@@ -66,18 +64,16 @@ public class ProxyUtil {
6664
* object as fallback; never {@code null})
6765
*/
6866
public static Class<?> ultimateTargetClass(Object candidate) {
69-
return targetClassCache.computeIfAbsent(candidate, k -> {
70-
Class<?> result = null;
71-
if (isSpringAopProxy(k)) {
72-
result = springUltimateTargetClass(k);
73-
} else if (isHibernateProxy(k)) {
74-
result = getHibernateProxyTarget(k).getClass();
75-
}
76-
if (result == null) {
77-
result = k.getClass();
78-
}
79-
return result;
80-
});
67+
Class<?> result = null;
68+
if (isSpringAopProxy(candidate)) {
69+
result = springUltimateTargetClass(candidate);
70+
} else if (isHibernateProxy(candidate)) {
71+
result = getHibernateProxyTarget(candidate).getClass();
72+
}
73+
if (result == null) {
74+
result = candidate.getClass();
75+
}
76+
return result;
8177
}
8278

8379
/**

0 commit comments

Comments
 (0)