[ https://issues.apache.org/jira/browse/WW-4485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482931#comment-14482931 ]
Jasper Rosenberg commented on WW-4485: -------------------------------------- Thanks, I will get right on testing it. Also, as an aside, I realized that there actually was a regression issue introduced by WW-4113 as well. Before, if a class had been loaded by different class loaders, then it was cached twice in ognl, which I think is the safest behavior. After WW-4113, because it was using the class's name, the same class name from different class loaders would be only cached once, with the first one in winning. > 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 > Reporter: Jasper Rosenberg > Priority: Blocker > Labels: ognl > Fix For: 2.5 > > > 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)