This is an automated email from the ASF dual-hosted git repository.

kusal pushed a commit to branch WW-5614-proxy-memory
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 11bc215c94bc2af8a6ccb59043b9154939914804
Author: Kusal Kithul-Godage <[email protected]>
AuthorDate: Thu Feb 12 12:46:17 2026 +1100

    WW-5614 Remove cache for ProxyUtil#ultimateTargetClass
---
 .../java/org/apache/struts2/util/ProxyUtil.java    | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/util/ProxyUtil.java 
b/core/src/main/java/org/apache/struts2/util/ProxyUtil.java
index a574af1c2..dbc1940e8 100644
--- a/core/src/main/java/org/apache/struts2/util/ProxyUtil.java
+++ b/core/src/main/java/org/apache/struts2/util/ProxyUtil.java
@@ -54,8 +54,6 @@ public class ProxyUtil {
             CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, 
CACHE_INITIAL_CAPACITY).buildOgnlCache();
     private static final OgnlCache<Member, Boolean> isProxyMemberCache = new 
DefaultOgnlCacheFactory<Member, Boolean>(
             CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, 
CACHE_INITIAL_CAPACITY).buildOgnlCache();
-    private static final OgnlCache<Object, Class<?>> targetClassCache = new 
DefaultOgnlCacheFactory<Object, Class<?>>(
-            CACHE_MAX_SIZE, OgnlCacheFactory.CacheType.WTLFU, 
CACHE_INITIAL_CAPACITY).buildOgnlCache();
 
     /**
      * Determine the ultimate target class of the given instance, traversing
@@ -66,18 +64,16 @@ public class ProxyUtil {
      * object as fallback; never {@code null})
      */
     public static Class<?> ultimateTargetClass(Object candidate) {
-        return targetClassCache.computeIfAbsent(candidate, k -> {
-            Class<?> result = null;
-            if (isSpringAopProxy(k)) {
-                result = springUltimateTargetClass(k);
-            } else if (isHibernateProxy(k)) {
-                result = getHibernateProxyTarget(k).getClass();
-            }
-            if (result == null) {
-                result = k.getClass();
-            }
-            return result;
-        });
+        Class<?> result = null;
+        if (isSpringAopProxy(candidate)) {
+            result = springUltimateTargetClass(candidate);
+        } else if (isHibernateProxy(candidate)) {
+            result = getHibernateProxyTarget(candidate).getClass();
+        }
+        if (result == null) {
+            result = candidate.getClass();
+        }
+        return result;
     }
 
     /**

Reply via email to