mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
72b1abd226
Prior to the introduction of the MergedAnnotation API in Spring Framework 5.2, our SynthesizedAnnotationInvocationHandler utilized a cache for annotation attribute values; whereas, the new SynthesizedMergedAnnotationInvocationHandler has no such caching in place. Issues such as gh-24961 indicate a regression in performance caused by the lack of such an attribute value cache. For example, the required attribute in @RequestParam is looked up using the internal meta-model in the MergedAnnotation API twice per request for each @RequestParam in a given controller handler method. This commit reintroduces the attribute value cache to avoid the unnecessary performance overhead associated with multiple lookups of the same attribute in a synthesized annotation. This applies not only to direct attribute method invocations but also to invocations of equals() and hashCode() on a synthesized annotation. Note, however, that this commit does NOT address multiple lookups of annotation attribute values for invocations of toString(). That behavior currently remains unchanged in the implementation of org.springframework.core.annotation.TypeMappedAnnotation.toString(). Closes gh-24970