Skip to content

Commit 1ac8e1c

Browse files
committed
Polishing
(cherry picked from commit a4a71a8)
1 parent 8b5d355 commit 1ac8e1c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/config/AutowireCapableBeanFactory.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String be
318318
* @param requiredType type the bean must match; can be an interface or superclass.
319319
* {@code null} is disallowed.
320320
* @return the bean name plus bean instance
321-
* @throws NoSuchBeanDefinitionException if no bean of the given type was found
322-
* @throws NoUniqueBeanDefinitionException if more than one bean of the given type was found
321+
* @throws NoSuchBeanDefinitionException if no matching bean was found
322+
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
323323
* @throws BeansException if the bean could not be created
324324
* @since 4.3.3
325325
* @see #getBean(Class)
@@ -328,30 +328,30 @@ Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String be
328328

329329
/**
330330
* Resolve the specified dependency against the beans defined in this factory.
331-
* @param descriptor the descriptor for the dependency
332-
* @param requestingBeanName the name of the bean which declares the present dependency
331+
* @param descriptor the descriptor for the dependency (field/method/constructor)
332+
* @param requestingBeanName the name of the bean which declares the given dependency
333333
* @return the resolved object, or {@code null} if none found
334334
* @throws NoSuchBeanDefinitionException if no matching bean was found
335335
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
336336
* @throws BeansException if dependency resolution failed for any other reason
337-
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
338337
* @since 2.5
338+
* @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
339339
*/
340340
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName) throws BeansException;
341341

342342
/**
343343
* Resolve the specified dependency against the beans defined in this factory.
344-
* @param descriptor the descriptor for the dependency
345-
* @param requestingBeanName the name of the bean which declares the present dependency
346-
* @param autowiredBeanNames a Set that all names of autowired beans (used for resolving
347-
* the present dependency) are supposed to be added to
344+
* @param descriptor the descriptor for the dependency (field/method/constructor)
345+
* @param requestingBeanName the name of the bean which declares the given dependency
346+
* @param autowiredBeanNames a Set that all names of autowired beans (used for
347+
* resolving the given dependency) are supposed to be added to
348348
* @param typeConverter the TypeConverter to use for populating arrays and collections
349349
* @return the resolved object, or {@code null} if none found
350350
* @throws NoSuchBeanDefinitionException if no matching bean was found
351351
* @throws NoUniqueBeanDefinitionException if more than one matching bean was found
352352
* @throws BeansException if dependency resolution failed for any other reason
353-
* @see DependencyDescriptor
354353
* @since 2.5
354+
* @see DependencyDescriptor
355355
*/
356356
Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName,
357357
Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ public <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws Bea
979979
private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object... args) throws BeansException {
980980
Assert.notNull(requiredType, "Required type must not be null");
981981
String[] beanNames = getBeanNamesForType(requiredType);
982+
982983
if (beanNames.length > 1) {
983984
ArrayList<String> autowireCandidates = new ArrayList<>();
984985
for (String beanName : beanNames) {
@@ -990,6 +991,7 @@ private <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType, Object...
990991
beanNames = autowireCandidates.toArray(new String[autowireCandidates.size()]);
991992
}
992993
}
994+
993995
if (beanNames.length == 1) {
994996
String beanName = beanNames[0];
995997
return new NamedBeanHolder<>(beanName, getBean(beanName, requiredType, args));
@@ -1009,6 +1011,7 @@ else if (beanNames.length > 1) {
10091011
}
10101012
throw new NoUniqueBeanDefinitionException(requiredType, candidates.keySet());
10111013
}
1014+
10121015
return null;
10131016
}
10141017

0 commit comments

Comments
 (0)