-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement
Description
Nikita Tovstoles opened SPR-9298 and commented
On each web request, RequestMappingHandlerAdapter.invokeHandlerMethod() indirectly calls MethodParameter.getParameterAnnotations(), which calls into JRE lib method causing monitor contention. See screen shots & YourKit snapshot. Most likely will need to patch spring (caching results of calls to java.lang.reflect.Method.getParameterAnnotations())
Looking at Spring's MethodParameter:
public Annotation[] getParameterAnnotations() {
if (this.parameterAnnotations == null) {
Annotation[][] annotationArray = (this.method != null ?
this.method.getParameterAnnotations() : this.constructor.getParameterAnnotations());
if (this.parameterIndex >= 0 && this.parameterIndex < annotationArray.length) {
this.parameterAnnotations = annotationArray[this.parameterIndex];
}
else {
this.parameterAnnotations = new Annotation[0];
}
}
return this.parameterAnnotations;
}
results of calls on Method & Constructor:
Annotation[][] annotationArray = (this.method != null ?
this.method.getParameterAnnotations() : this.constructor.getParameterAnnotations());
should be cached in two static Maps (since MethodParameter object is recreated per request)
Affects: 3.1 GA
Attachments:
- screenshot-1.jpg (224.28 kB)
- screenshot-2.jpg (291.28 kB)
Issue Links:
- Share MethodParameter cache between HandlerMethods [SPR-9748] #14382 Share MethodParameter cache between HandlerMethods ("duplicates")
- Look up of parameter annotations causes deadlock [SPR-8319] #12967 Look up of parameter annotations causes deadlock ("is duplicated by")
- annotations need to be cached (jvm concurrency issue) [SPR-8737] #13379 annotations need to be cached (jvm concurrency issue) ("is duplicated by")
0 votes, 7 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issueA duplicate of another issuetype: enhancementA general enhancementA general enhancement