Skip to content

monitor contention at org.springframework.core.MethodParameter.getParameterAnnotations() [SPR-9298] #13936

@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

0 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions