kusalk commented on code in PR #1236:
URL: https://github.com/apache/struts/pull/1236#discussion_r2796303839


##########
core/src/main/java/org/apache/struts2/util/ProxyUtil.java:
##########
@@ -65,15 +66,18 @@ public class ProxyUtil {
      * object as fallback; never {@code null})
      */
     public static Class<?> ultimateTargetClass(Object candidate) {
-        Class<?> result = null;
-        if (isSpringAopProxy(candidate))
-            result = springUltimateTargetClass(candidate);
-
-        if (result == null) {
-            result = candidate.getClass();
-        }
-
-        return result;
+        return targetClassCache.computeIfAbsent(candidate, k -> {

Review Comment:
   This specific cache does use the object as the key rather than the Class.
   
   > Also, as I understand, action is a request scope, so I'm not sure about 
what is the benefit of caching it
   
   This is true but the same request-scoped Action can be executed upon in 
multiple OGNL expressions. Also, Actions aren't the only objects being cached 
here.
   
   But yes you are right, it means all other referred objects from these 10,000 
cache keys will also be prevented from being GC'd.
   
   I think perhaps we should reduce the max size of this specific cache and 
also change the cache keys to weak references. I will see what I can do here.
   
   The best workaround you could apply today would be to use reflection upon 
application startup to reinitialise the `targetClassCache` static field with a 
cache of lower capacity.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to