mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-23 22:59:03 +00:00
Revised test for ImportBeanDefinitionRegistrar double scan
Issue: SPR-12334
(cherry picked from commit 6e5711a)
This commit is contained in:
+5
-3
@@ -33,6 +33,8 @@ public class Spr12334Tests {
|
||||
|
||||
@Test
|
||||
public void shouldNotScanTwice() {
|
||||
TestImport.scanned = false;
|
||||
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.scan(TestImport.class.getPackage().getName());
|
||||
context.refresh();
|
||||
@@ -53,14 +55,14 @@ public class Spr12334Tests {
|
||||
|
||||
public static class TestImport implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
private boolean scanned = false;
|
||||
private static boolean scanned = false;
|
||||
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
|
||||
if (this.scanned) {
|
||||
if (scanned) {
|
||||
throw new IllegalStateException("Already scanned");
|
||||
}
|
||||
this.scanned = true;
|
||||
scanned = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user