Lukasz Lenart created WW-5622:
---------------------------------

             Summary: Optimize Hibernate proxy detection to avoid repeated 
exception overhead when Hibernate is absent
                 Key: WW-5622
                 URL: https://issues.apache.org/jira/browse/WW-5622
             Project: Struts 2
          Issue Type: Improvement
          Components: Core
            Reporter: Lukasz Lenart
             Fix For: 6.9.0, 7.2.0


When Hibernate is not on the application classpath, Hibernate proxy detection 
methods throw and internally catch exceptions (NoClassDefFoundError in 6.x, 
LinkageError in 7.x) on every invocation. Applications with many distinct 
classes flowing through OGNL experience hundreds of thousands of caught 
exceptions, causing measurable performance degradation.

h3. Impact

The impact is most severe in Struts 6.x where 
{{com.opensymphony.xwork2.util.ProxyUtil}} lacks effective caching - 
{{isHibernateProxy()}} throws on nearly every call. Struts 7.x mitigates this 
partially via {{computeIfAbsent}} caching in {{StrutsProxyService}}, but still 
throws once per unique class/member.

h3. Fix

Detect Hibernate availability once at class-load time via {{Class.forName()}} 
and short-circuit all Hibernate-related methods immediately when absent. The 
existing {{try/catch}} blocks are retained as a safety net for partial 
classpath scenarios.

h3. Affected Classes

- 6.x: {{com.opensymphony.xwork2.util.ProxyUtil}}
- 7.x: {{org.apache.struts2.util.StrutsProxyService}} and deprecated 
{{org.apache.struts2.util.ProxyUtil}}

h3. Affected Methods

- {{isHibernateProxy()}}                                  
- {{isHibernateProxyMember()}}
- {{getHibernateProxyTarget()}}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to