<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=pcl" rel="nofollow">Patrick Linskey</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9748?redirect=false" rel="nofollow">SPR-9748</a></strong> and commented</p>
<p dir="auto">RequestMappingHandlerAdapter creates a new HandlerMethod for each request. HandlerMethods cache their MethodParameters to avoid costly reflection calls each time annotation stats are needed, but the per-request copy circumvents this cache. This patch explicitly copies the MethodParameter cache from a HandlerMethod and its request-scoped dependents.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1, 3.1.2, 3.2 M2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118478" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13936" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13936/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13936">#13936</a> monitor contention at org.springframework.core.MethodParameter.getParameterAnnotations() (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398173917" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/17058" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/17058/hovercard" href="https://github.com/spring-projects/spring-framework/issues/17058">#17058</a> NPE in org.springframework.core.MethodParameter.getParameterName (possible race condition)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398177812" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/17429" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/17429/hovercard" href="https://github.com/spring-projects/spring-framework/issues/17429">#17429</a> Thread contention in HandlerMethod due to unnecessary BeanFactory.getType call</li>
</ul>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/229537288a721ea1f73d7fee5ce9dd60ec46c23e/hovercard" href="https://github.com/spring-projects/spring-framework/commit/229537288a721ea1f73d7fee5ce9dd60ec46c23e"><tt>2295372</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/0a877afa061aacc67b238be6015bf82a3eecf0eb/hovercard" href="https://github.com/spring-projects/spring-framework/commit/0a877afa061aacc67b238be6015bf82a3eecf0eb"><tt>0a877af</tt></a></p>
<p dir="auto">1 votes, 3 watchers</p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=mck" rel="nofollow">mck</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-7949?redirect=false" rel="nofollow">SPR-7949</a></strong> and commented</p>
<p dir="auto">Under high-concurrent load situation, in an application using many prototype beans, contention occurs in DefaultSingletonBeanRegistry.getSingletonNames(..)</p>
<p dir="auto">This method has uses singletonObjects as a mutex for all map operations.<br>
Using a ReadWriteLock this contention could be removed, as in our case 99% of the calls here are read-only.</p>
<p dir="auto">We see hundreds of thread dumps like in a single jvm:</p>
<p dir="auto">java.lang.Thread.State: BLOCKED (on object monitor)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:180)</p>
<ul dir="auto">
<li>waiting to lock &lt;0x00007fb8519b11b0&gt; (a java.util.concurrent.ConcurrentHashMap)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:452)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:296)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:250)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)</li>
</ul>
<p dir="auto">java.lang.Thread.State: BLOCKED (on object monitor)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonNames(DefaultSingletonBeanRegistry.java:277)</p>
<ul dir="auto">
<li>waiting to lock &lt;0x00007fb856ab64d8&gt; (a java.util.concurrent.ConcurrentHashMap)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:352)<br>
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:829)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:744)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)<br>
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.resolvedCachedArgument(AutowiredAnnotationBeanPostProcessor.java:436)<br>
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.access$0(AutowiredAnnotationBeanPostProcessor.java:432)<br>
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:469)<br>
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)<br>
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:283)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)<br>
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBean(AbstractAutowireCapableBeanFactory.java:295)</li>
</ul>
<p dir="auto">java.lang.Thread.State: BLOCKED (on object monitor)<br>
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:180)</p>
<ul dir="auto">
<li>waiting to lock &lt;0x00007fb8519b11b0&gt; (a java.util.concurrent.ConcurrentHashMap)<br>
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:452)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:296)<br>
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:250)<br>
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083)</li>
</ul>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.0.4, 3.0.5</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/17615/SPR-7949.patch" rel="nofollow">SPR-7949.patch</a> (<em>15.19 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398103107" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/11536" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/11536/hovercard" href="https://github.com/spring-projects/spring-framework/issues/11536">#11536</a> Cache by-type lookups in DefaultListableBeanFactory (<em><strong>"duplicates"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398117731" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13828" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13828/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13828">#13828</a> Threads blocking on getSingleton method on DefaultSingletonBeanRegistry class  (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">17 votes, 16 watchers</p>