Jasper Rosenberg created WW-4485:
------------------------------------
Summary: New cacheKey is too expensive to create
Key: WW-4485
URL: https://issues.apache.org/jira/browse/WW-4485
Project: Struts 2
Issue Type: Bug
Components: Core Actions, Expression Language
Affects Versions: 2.5
Reporter: Jasper Rosenberg
Priority: Blocker
So we pushed ognl 3.0.10 to production this afternoon, and promptly had to
rollback because load on the servers went through the roof. Looking at the
stack traces, the issue was tons of threads doing this:
{noformat}
at java.lang.Class.getEnclosingMethod0(Native Method)
at java.lang.Class.getEnclosingMethodInfo(Class.java:1059)
at java.lang.Class.isLocalOrAnonymousClass(Class.java:1449)
at java.lang.Class.getCanonicalName(Class.java:1377)
at ognl.OgnlRuntime.buildCacheKey(OgnlRuntime.java:1944)
at ognl.OgnlRuntime.getGetMethod(OgnlRuntime.java:1926)
at ognl.OgnlRuntime.hasGetMethod(OgnlRuntime.java:1985)
at ognl.OgnlRuntime.hasGetProperty(OgnlRuntime.java:2045)
at
com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.getProperty(CompoundRootAccessor.java:141)
{noformat}
The problem is that the change to buildCacheKey() for
https://issues.apache.org/jira/browse/WW-4113 is way to expensive considering
how often it is called.
I'd like to suggest replacing the current buildCacheKey() implementation with
this:
{code:java}
private static Object buildCacheKey(Class targetClass, String propertyName)
{
return new CacheKey(targetClass, propertyName);
}
private static final class CacheKey {
private final Class clazz;
private final String propertyName;
public CacheKey(Class clazz, String propertyName) {
this.clazz = clazz;
this.propertyName = propertyName;
}
public boolean equals(Object obj) {
CacheKey cacheKey = (CacheKey) obj;
return clazz.equals(cacheKey.clazz)
&& propertyName.equals(cacheKey.propertyName);
}
public int hashCode() {
return clazz.hashCode() * 31 + propertyName.hashCode();
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)