Description
Hi,
I am running load tests with an application based on Apache Struts 2.5.26 and Spring Framework. In the thread dumps I took during the load tests, there are many many threads with stacktraces that tell me there is a synchronization in com.opensymphony.xwork2.TextProviderSupport.getText which blocks all other threads.
The jsp tag leading to that is for example:
<s:set var="variablename" value="getText('topic.find.value.field.name')"/>
The stack trace is then:
"http-nio-8080-exec-69" #144 daemon prio=5 os_prio=0 tid=0x0000000027b84000 nid=0x1ca4 waiting for monitor entry [0x000000003939b000]"http-nio-8080-exec-69" #144 daemon prio=5 os_prio=0 tid=0x0000000027b84000 nid=0x1ca4 waiting for monitor entry [0x000000002937b000] java.lang.Thread.State: BLOCKED (on object monitor) at java.util.Collections$SynchronizedCollection.contains(Collections.java:2021) - locked <0x00000009d3b1b8f0> (a java.util.Collections$SynchronizedSet) at com.opensymphony.xwork2.util.AbstractLocalizedTextProvider.findResourceBundle(AbstractLocalizedTextProvider.java:393) at com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.findResourceBundle(StrutsLocalizedTextProvider.java:39) at com.opensymphony.xwork2.util.AbstractLocalizedTextProvider.getMessage(AbstractLocalizedTextProvider.java:500) at com.opensymphony.xwork2.util.AbstractLocalizedTextProvider.findMessage(AbstractLocalizedTextProvider.java:537) at com.opensymphony.xwork2.util.AbstractLocalizedTextProvider.findMessage(AbstractLocalizedTextProvider.java:583) at com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.findText(StrutsLocalizedTextProvider.java:244) at com.opensymphony.xwork2.util.StrutsLocalizedTextProvider.findText(StrutsLocalizedTextProvider.java:166) at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:212) at com.opensymphony.xwork2.TextProviderSupport.getText(TextProviderSupport.java:127) at com.opensymphony.xwork2.ActionSupport.getText(ActionSupport.java:91) at sun.reflect.GeneratedMethodAccessor163.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at ognl.OgnlRuntime.invokeMethodInsideSandbox(OgnlRuntime.java:1266) at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:1251) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1969) at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68) at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:98) at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:83) at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:2045) at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.callMethod(CompoundRootAccessor.java:237) at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:2045) at ognl.ASTMethod.getValueBody(ASTMethod.java:97) at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) at ognl.SimpleNode.getValue(SimpleNode.java:258) at ognl.Ognl.getValue(Ognl.java:537) at ognl.Ognl.getValue(Ognl.java:501) at com.opensymphony.xwork2.ognl.OgnlUtil$2.execute(OgnlUtil.java:484) at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecute(OgnlUtil.java:523) at com.opensymphony.xwork2.ognl.OgnlUtil.getValue(OgnlUtil.java:482) at com.opensymphony.xwork2.ognl.OgnlValueStack.getValueUsingOgnl(OgnlValueStack.java:296) at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValue(OgnlValueStack.java:279) at com.opensymphony.xwork2.ognl.OgnlValueStack.tryFindValueWhenExpressionIsNotNull(OgnlValueStack.java:261) at com.opensymphony.xwork2.ognl.OgnlValueStack.findValue(OgnlValueStack.java:241) at org.apache.struts2.components.Component.findValue(Component.java:275) at org.apache.struts2.components.Set.end(Set.java:102) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:39)
Is it really needed to put this kind of synchronization there, which causes thread contention? Would for example a ConcurrentHashMap be possible?