Reintroduce synthesized annotation attribute value caching #24970
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: regression
A bug that is also a regression
Milestone
Prior to the introduction of the
MergedAnnotation
in Spring Framework 5.2, ourSynthesizedAnnotationInvocationHandler
utilized a cache for annotation attribute values; whereas, the newSynthesizedMergedAnnotationInvocationHandler
has no such caching in place.Issues such as #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 theMergedAnnotation
API twice per request for each@RequestParam
in a given controller handler method.Reintroducing the attribute value cache would avoid the unnecessary performance overhead associated with multiple lookups of the same attribute not only for use cases like
RequestParam.required
but also forequals()
andtoString()
invocations on a synthesized annotation. Note that invocations ofhashCode()
also incur additional overhead for attribute value lookups but only once, since the resulting hash code is cached after the first computation.The text was updated successfully, but these errors were encountered: