From ee8e178434e10f4dee0dbcdd78ea30b7aa6b1f53 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 12 Oct 2012 16:24:52 +0200 Subject: [PATCH] Only cache by-type lookups if configuration has been marked as frozen Issue: SPR-9448 --- .../beans/factory/support/DefaultListableBeanFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index fe7d2ebdd5..3468c599a5 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -304,8 +304,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } public String[] getBeanNamesForType(Class type, boolean includeNonSingletons, boolean allowEagerInit) { - if (type == null || !allowEagerInit) { - return this.doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); + if (!isConfigurationFrozen() || type == null || !allowEagerInit) { + return doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); } Map, String[]> cache = includeNonSingletons ? this.nonSingletonBeanNamesByType : this.singletonBeanNamesByType; @@ -313,7 +313,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (resolvedBeanNames != null) { return resolvedBeanNames; } - resolvedBeanNames = this.doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); + resolvedBeanNames = doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit); cache.put(type, resolvedBeanNames); return resolvedBeanNames; }