From f10abe7121fce292d4bd5493e078ed46783aeadd Mon Sep 17 00:00:00 2001 From: yokotaso Date: Thu, 6 Feb 2020 17:17:16 +0900 Subject: [PATCH] InjectionMetadata.EMPTY won't cached well in AutowiredAnnotationBeanPostProcessor#injectionMetadataCache org.springframework.beans.factory.annotation.InjectionMetadata#needsRefresh with InjectionMetadata.EMPTY always returns false, And therefore AutowiredAnnotationBeanPostProcessor#find always calls AutowiredAnnotationBeanPostProcessor#buildAutowiringMetadata As a result of this, Performance of constructing component degration happen from 5.1. Ref: https://github.com/spring-projects/spring-framework/issues/23905 --- .../beans/factory/annotation/InjectionMetadata.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java index 1d1fbd77cb72..bd275ea52945 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/InjectionMetadata.java @@ -153,6 +153,9 @@ public static InjectionMetadata forElements(Collection elements * @return {@code true} indicating a refresh, {@code false} otherwise */ public static boolean needsRefresh(@Nullable InjectionMetadata metadata, Class clazz) { + if (metadata == EMPTY) { + return false; + } return (metadata == null || metadata.targetClass != clazz); }