Skip to content

Commit b6b880c

Browse files
committed
Polishing
1 parent 7481d73 commit b6b880c

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

spring-beans/src/main/java/org/springframework/beans/BeanUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,7 @@ else if (startParen == -1) {
403403

404404

405405
/**
406-
* Retrieve the JavaBeans {@code PropertyDescriptor}s of a given
407-
* class.
406+
* Retrieve the JavaBeans {@code PropertyDescriptor}s of a given class.
408407
* @param clazz the Class to retrieve the PropertyDescriptors for
409408
* @return an array of {@code PropertyDescriptors} for the given class
410409
* @throws BeansException if PropertyDescriptor look fails

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public DisposableBeanAdapter(Object bean, String beanName, RootBeanDefinition be
115115
this.destroyMethod = determineDestroyMethod(destroyMethodName);
116116
if (this.destroyMethod == null) {
117117
if (beanDefinition.isEnforceDestroyMethod()) {
118-
throw new BeanDefinitionValidationException("Couldn't find a destroy method named '" +
118+
throw new BeanDefinitionValidationException("Could not find a destroy method named '" +
119119
destroyMethodName + "' on bean with name '" + beanName + "'");
120120
}
121121
}

spring-context/src/main/java/org/springframework/context/support/GenericApplicationContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ public final <T> void registerBean(Class<T> beanClass, BeanDefinitionCustomizer.
381381
* @param beanName the name of the bean (may be {@code null})
382382
* @param beanClass the class of the bean (resolving a public constructor
383383
* to be autowired, possibly simply the default constructor)
384-
* @param customizers one or more callbacks for customizing the
385-
* factory's {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
384+
* @param customizers one or more callbacks for customizing the factory's
385+
* {@link BeanDefinition}, e.g. setting a lazy-init or primary flag
386386
* @since 5.0
387387
* @see #registerBean(String, Class, Supplier, BeanDefinitionCustomizer...)
388388
*/

spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ public void getBeanByTypeRaisesNoSuchBeanDefinitionException() {
105105
}
106106
}
107107

108+
@Test
109+
public void getBeanByTypeAmbiguityRaisesException() {
110+
ApplicationContext context = new AnnotationConfigApplicationContext(TwoTestBeanConfig.class);
111+
112+
try {
113+
context.getBean(TestBean.class);
114+
}
115+
catch (NoSuchBeanDefinitionException ex) {
116+
assertThat(ex.getMessage(),
117+
allOf(
118+
containsString("No qualifying bean of type '" + TestBean.class.getName() + "'"),
119+
containsString("tb1"),
120+
containsString("tb2")
121+
)
122+
);
123+
}
124+
}
125+
108126
/**
109127
* Tests that Configuration classes are registered according to convention
110128
* @see org.springframework.beans.factory.support.DefaultBeanNameGenerator#generateBeanName
@@ -370,14 +388,6 @@ public TestBean testBean() {
370388
}
371389
}
372390

373-
static class ConfigMissingAnnotation {
374-
375-
@Bean
376-
public TestBean testBean() {
377-
return new TestBean();
378-
}
379-
}
380-
381391
@Configuration
382392
static class TwoTestBeanConfig {
383393

0 commit comments

Comments
 (0)