[
https://issues.apache.org/jira/browse/WW-5514?focusedWorklogId=1006470&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1006470
]
ASF GitHub Bot logged work on WW-5514:
--------------------------------------
Author: ASF GitHub Bot
Created on: 21/Feb/26 08:33
Start Date: 21/Feb/26 08:33
Worklog Time Spent: 10m
Work Description: 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
Issue Time Tracking
-------------------
Worklog Id: (was: 1006470)
Time Spent: 3h (was: 2h 50m)
> Allow configuration of ProxyUtil for cache types
> ------------------------------------------------
>
> Key: WW-5514
> URL: https://issues.apache.org/jira/browse/WW-5514
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 6.6.0
> Reporter: Jon Pulice
> Assignee: Lukasz Lenart
> Priority: Minor
> Fix For: 6.9.0, 7.2.0
>
> Time Spent: 3h
> Remaining Estimate: 0h
>
> Since 6.6.0, the ProxyUtil class now always uses the WTLFU cache type when
> creating its two internal caches. This means that the caffeine
> library is now mandatory when it was not before.
> {code:java}
> private static final OgnlCache<Class<?>, Boolean> isProxyCache = (new
> DefaultOgnlCacheFactory(10000, OgnlCacheFactory.CacheType.WTLFU, 256))
> .buildOgnlCache();
> private static final OgnlCache<Member, Boolean> isProxyMemberCache = (new
> DefaultOgnlCacheFactory(10000, OgnlCacheFactory.CacheType.WTLFU, 256))
> .buildOgnlCache();{code}
>
> Prior to 6.6.0, setting both of these configuration options would allow you
> to omit the caffeine dependency from an application:
> {code:java}
> <constant name="struts.ognl.expressionCacheType" value ="basic" />
> <constant name="struts.ognl.beanInfoCacheType" value="basic" />{code}
>
> Would it be possible to allow for the cache type used by the ProxyUtil class
> to be configurable as well similar to the above?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)