Skip to content

Commit

Permalink
fix (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 authored Feb 19, 2024
1 parent 7d71798 commit b5abbf6
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public abstract class NamedContextFactory<C extends NamedContextFactory.Specific

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

private Map<String, C> configurations = new ConcurrentHashMap<>();
private final Map<String, C> configurations = new ConcurrentHashMap<>();

private ApplicationContext parent;

private Class<?> defaultConfigType;
private final Class<?> defaultConfigType;

public NamedContextFactory(Class<?> defaultConfigType, String propertySourceName, String propertyName) {
this(defaultConfigType, propertySourceName, propertyName, new HashMap<>());
Expand Down Expand Up @@ -222,11 +222,9 @@ public <T> T getInstance(String name, Class<?> clazz, Class<?>... generics) {
public <T> T getInstance(String name, ResolvableType type) {
GenericApplicationContext context = getContext(name);
String[] beanNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(context, type);
if (beanNames.length > 0) {
for (String beanName : beanNames) {
if (context.isTypeMatch(beanName, type)) {
return (T) context.getBean(beanName);
}
for (String beanName : beanNames) {
if (context.isTypeMatch(beanName, type)) {
return (T) context.getBean(beanName);
}
}
return null;
Expand Down

0 comments on commit b5abbf6

Please sign in to comment.