ControllerAdviceBean accepts bean types without @ControllerAdvice annotation (as in 3.2)

Issue: SPR-13759
master
Juergen Hoeller 9 years ago
parent 415b92b6d1
commit d64ac32e3d
  1. 12
      spring-web/src/main/java/org/springframework/web/method/ControllerAdviceBean.java

@ -19,6 +19,7 @@ package org.springframework.web.method;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@ -102,14 +103,17 @@ public class ControllerAdviceBean implements Ordered {
}
ControllerAdvice annotation = AnnotationUtils.findAnnotation(beanType, ControllerAdvice.class);
if (annotation == null) {
throw new IllegalArgumentException(
"Bean type [" + beanType.getName() + "] is not annotated as @ControllerAdvice");
}
if (annotation != null) {
this.basePackages = initBasePackages(annotation);
this.assignableTypes = Arrays.asList(annotation.assignableTypes());
this.annotations = Arrays.asList(annotation.annotations());
}
else {
this.basePackages = Collections.emptySet();
this.assignableTypes = Collections.emptyList();
this.annotations = Collections.emptyList();
}
}
/**

Loading…
Cancel
Save