From 52f1a3aef9d31f620849e410879cefefcac37e8c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Fri, 21 Jun 2019 17:11:12 +0300 Subject: [PATCH] Polish ControllerAdviceBean --- .../web/method/ControllerAdviceBean.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java index e0c1710088..440cecdacd 100644 --- a/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java +++ b/spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java @@ -70,9 +70,10 @@ public class ControllerAdviceBean implements Ordered { /** * Create a {@code ControllerAdviceBean} using the given bean name. * @param beanName the name of the bean - * @param beanFactory a BeanFactory that can be used later to resolve the bean + * @param beanFactory a {@code BeanFactory} to retrieve the bean type initially + * and later to resolve the actual bean */ - public ControllerAdviceBean(String beanName, @Nullable BeanFactory beanFactory) { + public ControllerAdviceBean(String beanName, BeanFactory beanFactory) { this((Object) beanName, beanFactory); } @@ -83,7 +84,7 @@ public class ControllerAdviceBean implements Ordered { if (bean instanceof String) { String beanName = (String) bean; - Assert.hasText(beanName, "Bean name must not be null"); + Assert.hasText(beanName, "Bean name must not be empty"); Assert.notNull(beanFactory, "BeanFactory must not be null"); if (!beanFactory.containsBean(beanName)) { throw new IllegalArgumentException("BeanFactory [" + beanFactory + @@ -140,7 +141,8 @@ public class ControllerAdviceBean implements Ordered { } /** - * Return a bean instance if necessary resolving the bean name through the BeanFactory. + * Get the bean instance for this {@code ControllerAdviceBean}, if necessary + * resolving the bean name through the {@link BeanFactory}. */ public Object resolveBean() { return (this.bean instanceof String ? obtainBeanFactory().getBean((String) this.bean) : this.bean);