Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look up of parameter annotations causes deadlock [SPR-8319] #12967

Closed
spring-projects-issues opened this issue May 9, 2011 · 2 comments
Closed
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 9, 2011

Johannes Tuchscherer opened SPR-8319 and commented

When there are a lot of requests hitting a request method with parameter annotations we occasionally get a deadlock in the jvm (see below for stack trace). I think this could be easily fixed in the org.springframework.core.HandlerMethodInvoker, if - instead of creating a new instance of MethodParameter every time (line 243) - the methodParameters and their annotations would be cached. This would also give us a nice performance gain, since we don't need to lookup annotations every time the request method is called.

java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:417) - waiting to lock <0x00000000ac1166d0> (a java.util.HashMap)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations2(AnnotationParser.java:133)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations(AnnotationParser.java:110)
at java.lang.reflect.Method.getParameterAnnotations(Method.java:751)
at org.springframework.core.MethodParameter.getParameterAnnotations(MethodParameter.java:232)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:246)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:169)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)

Blocked by:

java.lang.Thread.State: BLOCKED (on object monitor)
at java.util.AbstractList.iterator(AbstractList.java:273)
at java.util.AbstractList.hashCode(AbstractList.java:524)
at java.util.HashMap.get(HashMap.java:300)
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:426) - locked <0x00000000ac1166d0> (a java.util.HashMap)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations2(AnnotationParser.java:133)
at sun.reflect.annotation.AnnotationParser.parseParameterAnnotations(AnnotationParser.java:110)
at java.lang.reflect.Method.getParameterAnnotations(Method.java:751)
at org.springframework.core.MethodParameter.getParameterAnnotations(MethodParameter.java:232)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:246)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:169)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:421)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:409)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)


Affects: 3.0.2

Issue Links:

1 votes, 2 watchers

@spring-projects-issues
Copy link
Collaborator Author

Ronnie Roberts commented

We are running some high-volume load tests and seeing the same. Tomcat 6.0.32 Spring 3.0.5. Is there any resolution to this issue?

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 16, 2012

Chris Beams commented

This issue has just been fixed with the resolution of #13936.

Please give the latest 3.2.0.BUILD-SNAPSHOT a try and let us know (in comments on #13936) how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

1 participant