Isolated circular import detection for scanned configuration classes

Issue: SPR-14517
This commit is contained in:
Juergen Hoeller
2016-07-27 16:21:48 +02:00
parent fd9e88d372
commit 316244d2bd
2 changed files with 23 additions and 4 deletions

View File

@@ -139,7 +139,7 @@ class ConfigurationClassParser {
private final List<String> propertySourceNames = new ArrayList<>();
private final ImportStack importStack = new ImportStack();
private ImportStack importStack = new ImportStack();
private List<DeferredImportSelectorHolder> deferredImportSelectors;
@@ -276,7 +276,16 @@ class ConfigurationClassParser {
// Check the set of scanned definitions for any further config classes and parse recursively if necessary
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
// Provide isolated circular import detection for scanned classes,
// since the initial registration did not come explicitly.
ImportStack previousStack = this.importStack;
this.importStack = new ImportStack();
try {
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
}
finally {
this.importStack = previousStack;
}
}
}
}