lukaszlenart commented on code in PR #1573:
URL: https://github.com/apache/struts/pull/1573#discussion_r2835984042


##########
core/src/main/java/com/opensymphony/xwork2/util/ProxyUtil.java:
##########
@@ -51,15 +51,64 @@ public class ProxyUtil {
     private static final String HIBERNATE_HIBERNATEPROXY_CLASS_NAME = 
"org.hibernate.proxy.HibernateProxy";
     private static final int CACHE_MAX_SIZE = 10000;
     private static final int CACHE_INITIAL_CAPACITY = 256;
-    private static final OgnlCache<Class<?>, Boolean> isProxyCache = new 
DefaultOgnlCacheFactory<Class<?>, Boolean>(
-            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();
+
+    // Holder for the cache factory (set by container)
+    private static volatile ProxyCacheFactory<?, ?> cacheFactory;
+
+    // Lazy-initialized caches
+    private static volatile OgnlCache<Class<?>, Boolean> isProxyCache;
+    private static volatile OgnlCache<Member, Boolean> isProxyMemberCache;
+
+    /**
+     * Sets the cache factory. Called by the container during initialization.
+     *
+     * @param factory the cache factory to use for creating proxy caches
+     * @since 6.8.0
+     */
+    public static void setProxyCacheFactory(ProxyCacheFactory<?, ?> factory) {
+        cacheFactory = factory;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static OgnlCache<Class<?>, Boolean> getIsProxyCache() {
+        if (isProxyCache == null) {

Review Comment:
   Done, thanks for this idea :)



##########
core/src/main/java/com/opensymphony/xwork2/util/ProxyUtil.java:
##########
@@ -51,15 +51,64 @@ public class ProxyUtil {
     private static final String HIBERNATE_HIBERNATEPROXY_CLASS_NAME = 
"org.hibernate.proxy.HibernateProxy";
     private static final int CACHE_MAX_SIZE = 10000;
     private static final int CACHE_INITIAL_CAPACITY = 256;
-    private static final OgnlCache<Class<?>, Boolean> isProxyCache = new 
DefaultOgnlCacheFactory<Class<?>, Boolean>(
-            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();
+
+    // Holder for the cache factory (set by container)
+    private static volatile ProxyCacheFactory<?, ?> cacheFactory;
+
+    // Lazy-initialized caches
+    private static volatile OgnlCache<Class<?>, Boolean> isProxyCache;
+    private static volatile OgnlCache<Member, Boolean> isProxyMemberCache;
+
+    /**
+     * Sets the cache factory. Called by the container during initialization.
+     *
+     * @param factory the cache factory to use for creating proxy caches
+     * @since 6.8.0
+     */
+    public static void setProxyCacheFactory(ProxyCacheFactory<?, ?> factory) {
+        cacheFactory = factory;

Review Comment:
   Done



-- 
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