|
31 | 31 | import java.util.HashSet; |
32 | 32 | import java.util.LinkedHashSet; |
33 | 33 | import java.util.List; |
34 | | -import java.util.Map; |
35 | 34 | import java.util.Set; |
36 | 35 | import java.util.TreeSet; |
37 | 36 | import java.util.concurrent.ConcurrentHashMap; |
@@ -156,11 +155,14 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac |
156 | 155 | private final NamedThreadLocal<String> currentlyCreatedBean = new NamedThreadLocal<>("Currently created bean"); |
157 | 156 |
|
158 | 157 | /** Cache of unfinished FactoryBean instances: FactoryBean name to BeanWrapper. */ |
159 | | - private final Map<String, BeanWrapper> factoryBeanInstanceCache = new ConcurrentHashMap<>(16); |
| 158 | + private final ConcurrentMap<String, BeanWrapper> factoryBeanInstanceCache = new ConcurrentHashMap<>(); |
| 159 | + |
| 160 | + /** Cache of candidate factory methods per factory class. */ |
| 161 | + private final ConcurrentMap<Class<?>, Method[]> factoryMethodCandidateCache = new ConcurrentHashMap<>(); |
160 | 162 |
|
161 | 163 | /** Cache of filtered PropertyDescriptors: bean Class to PropertyDescriptor array. */ |
162 | 164 | private final ConcurrentMap<Class<?>, PropertyDescriptor[]> filteredPropertyDescriptorsCache = |
163 | | - new ConcurrentHashMap<>(256); |
| 165 | + new ConcurrentHashMap<>(); |
164 | 166 |
|
165 | 167 |
|
166 | 168 | /** |
@@ -716,7 +718,9 @@ protected Class<?> getTypeForFactoryMethod(String beanName, RootBeanDefinition m |
716 | 718 | Method uniqueCandidate = null; |
717 | 719 | int minNrOfArgs = |
718 | 720 | (mbd.hasConstructorArgumentValues() ? mbd.getConstructorArgumentValues().getArgumentCount() : 0); |
719 | | - Method[] candidates = ReflectionUtils.getUniqueDeclaredMethods(factoryClass); |
| 721 | + Method[] candidates = this.factoryMethodCandidateCache.computeIfAbsent( |
| 722 | + factoryClass, ReflectionUtils::getUniqueDeclaredMethods); |
| 723 | + |
720 | 724 | for (Method candidate : candidates) { |
721 | 725 | if (Modifier.isStatic(candidate.getModifiers()) == isStatic && mbd.isFactoryMethod(candidate) && |
722 | 726 | candidate.getParameterCount() >= minNrOfArgs) { |
|
0 commit comments