You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ku...@apache.org on 2026/02/12 01:46:29 UTC

(struts) branch WW-5614-proxy-memory created (now 11bc215c9)

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

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


      at 11bc215c9 WW-5614 Remove cache for ProxyUtil#ultimateTargetClass

This branch includes the following new commits:

     new 11bc215c9 WW-5614 Remove cache for ProxyUtil#ultimateTargetClass

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(struts) 01/01: WW-5614 Remove cache for ProxyUtil#ultimateTargetClass

Posted by ku...@apache.org.
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 <gi...@kusal.io>
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;
     }
 
     /**