Skip to content

Commit ee8e178

Browse files
committed
Only cache by-type lookups if configuration has been marked as frozen
Issue: SPR-9448
1 parent 679e122 commit ee8e178

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,16 @@ public String[] getBeanNamesForType(Class<?> type) {
304304
}
305305

306306
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
307-
if (type == null || !allowEagerInit) {
308-
return this.doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit);
307+
if (!isConfigurationFrozen() || type == null || !allowEagerInit) {
308+
return doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit);
309309
}
310310
Map<Class<?>, String[]> cache = includeNonSingletons ?
311311
this.nonSingletonBeanNamesByType : this.singletonBeanNamesByType;
312312
String[] resolvedBeanNames = cache.get(type);
313313
if (resolvedBeanNames != null) {
314314
return resolvedBeanNames;
315315
}
316-
resolvedBeanNames = this.doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit);
316+
resolvedBeanNames = doGetBeanNamesForType(type, includeNonSingletons, allowEagerInit);
317317
cache.put(type, resolvedBeanNames);
318318
return resolvedBeanNames;
319319
}

0 commit comments

Comments
 (0)