You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2015/04/07 11:45:12 UTC
[jira] [Commented] (WW-4485) New cacheKey is too expensive to
create
[ https://issues.apache.org/jira/browse/WW-4485?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14482923#comment-14482923 ]
Lukasz Lenart commented on WW-4485:
-----------------------------------
Sorry to hear that, I have pushed your changes into GitHub, can you test 3.0.11-SNAPSHOT? So then I will be able to push a new release
> 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)