Skip to content

Commit 52f1a3a

Browse files
committed
Polish ControllerAdviceBean
1 parent beb454a commit 52f1a3a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ public ControllerAdviceBean(Object bean) {
7070
/**
7171
* Create a {@code ControllerAdviceBean} using the given bean name.
7272
* @param beanName the name of the bean
73-
* @param beanFactory a BeanFactory that can be used later to resolve the bean
73+
* @param beanFactory a {@code BeanFactory} to retrieve the bean type initially
74+
* and later to resolve the actual bean
7475
*/
75-
public ControllerAdviceBean(String beanName, @Nullable BeanFactory beanFactory) {
76+
public ControllerAdviceBean(String beanName, BeanFactory beanFactory) {
7677
this((Object) beanName, beanFactory);
7778
}
7879

@@ -83,7 +84,7 @@ private ControllerAdviceBean(Object bean, @Nullable BeanFactory beanFactory) {
8384

8485
if (bean instanceof String) {
8586
String beanName = (String) bean;
86-
Assert.hasText(beanName, "Bean name must not be null");
87+
Assert.hasText(beanName, "Bean name must not be empty");
8788
Assert.notNull(beanFactory, "BeanFactory must not be null");
8889
if (!beanFactory.containsBean(beanName)) {
8990
throw new IllegalArgumentException("BeanFactory [" + beanFactory +
@@ -140,7 +141,8 @@ public Class<?> getBeanType() {
140141
}
141142

142143
/**
143-
* Return a bean instance if necessary resolving the bean name through the BeanFactory.
144+
* Get the bean instance for this {@code ControllerAdviceBean}, if necessary
145+
* resolving the bean name through the {@link BeanFactory}.
144146
*/
145147
public Object resolveBean() {
146148
return (this.bean instanceof String ? obtainBeanFactory().getBean((String) this.bean) : this.bean);

0 commit comments

Comments
 (0)