|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2015 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
19 | 19 | import java.lang.annotation.Annotation;
|
20 | 20 | import java.util.ArrayList;
|
21 | 21 | import java.util.Arrays;
|
| 22 | +import java.util.Collections; |
22 | 23 | import java.util.LinkedHashSet;
|
23 | 24 | import java.util.List;
|
24 | 25 | import java.util.Set;
|
@@ -102,13 +103,16 @@ private ControllerAdviceBean(Object bean, BeanFactory beanFactory) {
|
102 | 103 | }
|
103 | 104 |
|
104 | 105 | ControllerAdvice annotation = AnnotationUtils.findAnnotation(beanType, ControllerAdvice.class);
|
105 |
| - if (annotation == null) { |
106 |
| - throw new IllegalArgumentException( |
107 |
| - "Bean type [" + beanType.getName() + "] is not annotated as @ControllerAdvice"); |
| 106 | + if (annotation != null) { |
| 107 | + this.basePackages = initBasePackages(annotation); |
| 108 | + this.assignableTypes = Arrays.asList(annotation.assignableTypes()); |
| 109 | + this.annotations = Arrays.asList(annotation.annotations()); |
| 110 | + } |
| 111 | + else { |
| 112 | + this.basePackages = Collections.emptySet(); |
| 113 | + this.assignableTypes = Collections.emptyList(); |
| 114 | + this.annotations = Collections.emptyList(); |
108 | 115 | }
|
109 |
| - this.basePackages = initBasePackages(annotation); |
110 |
| - this.assignableTypes = Arrays.asList(annotation.assignableTypes()); |
111 |
| - this.annotations = Arrays.asList(annotation.annotations()); |
112 | 116 | }
|
113 | 117 |
|
114 | 118 |
|
|
0 commit comments