Skip to content

Commit b5abbf6

Browse files
authored
fix (#1338)
1 parent 7d71798 commit b5abbf6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

spring-cloud-context/src/main/java/org/springframework/cloud/context/named/NamedContextFactory.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public abstract class NamedContextFactory<C extends NamedContextFactory.Specific
6767

6868
private final Map<String, GenericApplicationContext> contexts = new ConcurrentHashMap<>();
6969

70-
private Map<String, C> configurations = new ConcurrentHashMap<>();
70+
private final Map<String, C> configurations = new ConcurrentHashMap<>();
7171

7272
private ApplicationContext parent;
7373

74-
private Class<?> defaultConfigType;
74+
private final Class<?> defaultConfigType;
7575

7676
public NamedContextFactory(Class<?> defaultConfigType, String propertySourceName, String propertyName) {
7777
this(defaultConfigType, propertySourceName, propertyName, new HashMap<>());
@@ -222,11 +222,9 @@ public <T> T getInstance(String name, Class<?> clazz, Class<?>... generics) {
222222
public <T> T getInstance(String name, ResolvableType type) {
223223
GenericApplicationContext context = getContext(name);
224224
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type);
225-
if (beanNames.length > 0) {
226-
for (String beanName : beanNames) {
227-
if (context.isTypeMatch(beanName, type)) {
228-
return (T) context.getBean(beanName);
229-
}
225+
for (String beanName : beanNames) {
226+
if (context.isTypeMatch(beanName, type)) {
227+
return (T) context.getBean(beanName);
230228
}
231229
}
232230
return null;

0 commit comments

Comments
 (0)