-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bugtype: documentationA documentation taskA documentation task
Milestone
Description
Affects: 5.x
See below test case:
import org.testng.annotations.Test;
import org.testng.Assert;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
public class NullBeanIssue {
@Test
public void test_shouldGetNull() {
var ctx = new AnnotationConfigApplicationContext();
ctx.register(MyFactoryBean.class);
ctx.refresh();
var myBean = ctx.getBean("myBean");
// expects null because MyFactoryBean.myBean returns null,
// however, I got a NullBean instance here
Assert.assertNull(myBean);
ctx.close();
}
}
class MyBean {
}
class MyFactoryBean {
@Bean
public MyBean myBean() {
return null; // in real project cases, return value might be null or not null that depends.
}
}
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchesAn issue that has been backported to maintenance branchestype: bugA general bugA general bugtype: documentationA documentation taskA documentation task