kusalk commented on code in PR #1586: URL: https://github.com/apache/struts/pull/1586#discussion_r2832676933
########## core/src/main/java/org/apache/struts2/util/StrutsProxyService.java: ########## @@ -0,0 +1,198 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.util; + +import org.apache.commons.lang3.reflect.ConstructorUtils; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.commons.lang3.reflect.MethodUtils; +import org.apache.struts2.inject.Inject; +import org.apache.struts2.ognl.OgnlCache; +import org.apache.struts2.ognl.ProxyCacheFactory; +import org.hibernate.Hibernate; +import org.hibernate.proxy.HibernateProxy; +import org.springframework.aop.TargetClassAware; +import org.springframework.aop.framework.Advised; +import org.springframework.aop.framework.AopProxyUtils; +import org.springframework.aop.support.AopUtils; +import org.springframework.aop.SpringProxy; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import java.lang.reflect.Method; + +import static java.lang.reflect.Modifier.isPublic; +import static java.lang.reflect.Modifier.isStatic; + +/** + * Default implementation of {@link ProxyService}. + * Provides proxy detection and resolution for Spring AOP and Hibernate proxies. + * + * @since 7.2.0 + */ +public class StrutsProxyService implements ProxyService { + + private final OgnlCache<Class<?>, Boolean> isProxyCache; + private final OgnlCache<Member, Boolean> isProxyMemberCache; + private final OgnlCache<Object, Class<?>> targetClassCache; Review Comment: I deleted this cache in #1578—let's not bring it back in this PR. We need to rethink the memory impact before doing so, I've got some ideas but haven't had a chance to test them yet ########## core/src/main/java/org/apache/struts2/util/ProxyUtil.java: ########## Review Comment: Let's change these 2 static caches to `BASIC` too for good measure. I know they technically shouldn't be used for anything anymore, but just in case some class tries to read this class it'll cause a hard requirement on Caffeine again ########## core/src/main/resources/org/apache/struts2/default.properties: ########## @@ -283,6 +283,19 @@ struts.ognl.beanInfoCacheType=wtlfu ### application-specific needs. struts.ognl.beanInfoCacheMaxSize=10000 +### Specifies the type of cache to use for proxy detection. See StrutsConstants class for further information. +### Using 'basic' by default to avoid mandatory Caffeine dependency. +struts.proxy.cacheType=basic Review Comment: All the other caches default to `wtlfu` (i.e. performant by default), let's do that here too -- 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]
