ConfigurationClassEnhancer leniently allows for null bean references
Issue: SPR-15829
This commit is contained in:
@@ -205,6 +205,15 @@ public class ConfigurationClassProcessingTests {
|
||||
assertNotSame(bar.getSpouse(), baz);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationWithNullReference() {
|
||||
BeanFactory factory = initBeanFactory(ConfigWithNullReference.class);
|
||||
|
||||
TestBean foo = factory.getBean("foo", TestBean.class);
|
||||
assertTrue(factory.getBean("bar").equals(null));
|
||||
assertNull(foo.getSpouse());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configurationWithAdaptivePrototypes() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
@@ -307,7 +316,7 @@ public class ConfigurationClassProcessingTests {
|
||||
|
||||
static TestBean testBean = new TestBean(ConfigWithBeanWithAliases.class.getSimpleName());
|
||||
|
||||
@Bean(name = { "name1", "alias1", "alias2", "alias3" })
|
||||
@Bean(name = {"name1", "alias1", "alias2", "alias3"})
|
||||
public TestBean methodName() {
|
||||
return testBean;
|
||||
}
|
||||
@@ -319,7 +328,7 @@ public class ConfigurationClassProcessingTests {
|
||||
|
||||
static TestBean testBean = new TestBean(ConfigWithBeanWithAliasesConfiguredViaValueAttribute.class.getSimpleName());
|
||||
|
||||
@Bean({ "enigma", "alias1", "alias2", "alias3" })
|
||||
@Bean({"enigma", "alias1", "alias2", "alias3"})
|
||||
public TestBean methodName() {
|
||||
return testBean;
|
||||
}
|
||||
@@ -415,6 +424,16 @@ public class ConfigurationClassProcessingTests {
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class ConfigWithNullReference extends ConfigWithPrototypeBean {
|
||||
|
||||
@Override
|
||||
public TestBean bar() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Scope("prototype")
|
||||
static class AdaptiveInjectionPoints {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user