Commit e233c325 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #13989 from izeye:scan-package

* pr/13989:
  Update assertion message in AnnotatedClassFinder.scanPackage()
parents b9fcb6a5 d92441e5
......@@ -41,6 +41,8 @@ public final class AnnotatedClassFinder {
private static final Map<String, Class<?>> cache = Collections
.synchronizedMap(new Cache(40));
private final Class<? extends Annotation> annotationType;
private final ClassPathScanningCandidateComponentProvider scanner;
/**
......@@ -49,6 +51,7 @@ public final class AnnotatedClassFinder {
*/
public AnnotatedClassFinder(Class<? extends Annotation> annotationType) {
Assert.notNull(annotationType, "AnnotationType must not be null");
this.annotationType = annotationType;
this.scanner = new ClassPathScanningCandidateComponentProvider(false);
this.scanner.addIncludeFilter(new AnnotationTypeFilter(annotationType));
this.scanner.setResourcePattern("*.class");
......@@ -88,8 +91,8 @@ public final class AnnotatedClassFinder {
Set<BeanDefinition> components = this.scanner.findCandidateComponents(source);
if (!components.isEmpty()) {
Assert.state(components.size() == 1,
() -> "Found multiple @SpringBootConfiguration annotated classes "
+ components);
() -> "Found multiple @" + this.annotationType.getSimpleName()
+ " annotated classes " + components);
return ClassUtils.resolveClassName(
components.iterator().next().getBeanClassName(), null);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment